我有一个工作的 matlab/octave m 文件,但是当我将 M 文件转换为函数并运行它时,函数中出现错误,在第 7 行第 16 列附近未定义“函数名称”。
请参阅下面的 workng M 文件:
clear all, clc,clf,tic
fs=360;
t=linspace(0,2*pi,fs);
y=sinc(t*1);
sigarray=y;
fs=length(sigarray);
aa_sig_combined_L=zeros(1,length(fs)); %need to reset or will get noise at the end
a_L=zeros(1,length(sigarray));
cycle_permute_lt = @(sigarray, k) [sigarray(mod((1:end)+k-1, end)+1 )];
array_phase_shift_div_num=360/mod(180,360) %keep at 360 to get correct deg angles
array_phase_shift=round(fs/array_phase_shift_div_num) %will keep within 360 degs
for ii=0:1:fs
a_L=cycle_permute_lt(sigarray, ii+array_phase_shift);
aa_sig_combined_L = aa_sig_combined_L + a_L;
end;
array_shifted=aa_sig_combined_L;
subplot(2,1,1),plot(t,y),
title('original')
subplot(2,1,2),plot(t,aa_sig_combined_L)
str_title='aa_sig_combined_L';
title(str_title,'Interpreter','none') %turns of latex interperter so I can use underscores my way
请参阅下面创建的 M 文件和函数在访问时不起作用
clear all, clc,clf,tic
fs=360;
t=linspace(0,2*pi,fs);
y=sinc(t*1);
sigarray=y;
[array_shifted]=rtpsa(y,180)
功能如下:
function [array_shifted]=rtpsa(sigarray,deg_to_shift)
fs=length(sigarray)
aa_sig_combined_L=zeros(1,length(fs)); %need to reset or will get noise at the end
a_L=zeros(1,length(sigarray));
cycle_permute_lt = @(sigarray, k) [sigarray(mod((1:end)+k-1, end)+1 )];
array_phase_shift_div_num=360/mod(deg_to_shift,360) %keep at 360 to get correct deg angles
array_phase_shift=round(fs/array_phase_shift_div_num) %will keep within 360 degs
for ii=0:1:fs
a_L=cycle_permute_lt(sigarray, ii+array_phase_shift);
aa_sig_combined_L = aa_sig_combined_L + a_L;
end;
array_shifted=aa_sig_combined_L;
end;
我正在使用 octave 版本 3.2.4 和 ubuntu 10.04 linux