作为MatLab的新手,我在运行以下脚本时遇到问题:
function [ newarray ] = reshapeIm( array, period )
%reshapeIm(array, period) Summary of this function goes here
% Detailed explanation goes here
le = length(array);
fra = le/period;
array = [array, zeros(1, ceil(fra)*period-le)];
newarray = reshape(array', period, []);
end
load('1200rpm_shak3.mat');
cRounds = 54;
mylength = 100;
thetas = (1:cRounds*mylength).*2*pi/mylength;
thetas0 = (1:mylength).*2*pi/mylength;
figure;
plot(z1(1:300), '.-');
plot(z2(1:300), '.-');
z1s = z1;
z2s = [z2(mylength/4+1:end) z2(1:mylength/4)];
z3s = [z3(mylength/2+1:end) z3(1:mylength/2)];
z4s = [z4(mylength*3/4+1:end) z4(1:mylength*3/4)];
dr = 1/4.*(z1s+z2s+z3s+z4s); % gemittelt
drs = reshapeIm(dr, mylength);
drs_std = std(drs, 1, 2);
drs_meanstd = mean(drs_std);
figure;
polar(thetas, 250000+200*dr);
figure;
polar(thetas0', 250000+200*mean(drs,2));
命令窗口显示:
??? Error using ==> run
Input argument 'array' is undefined.
我想,那是因为脚本是为较新的MatLab编写的,但我使用5.3。
答案 0 :(得分:1)
功能需要在他们自己的文件中。您无法在脚本文件中定义函数。因此,要使代码完全正常工作,您需要将位于文件顶部的函数(我在下面复制的函数)移动到自己的文件中。将文件命名为“reshapeIM.m”并将其保存在您正在工作的同一目录中。
function [ newarray ] = reshapeIm( array, period )
%reshapeIm(array, period) Summary of this function goes here
% Detailed explanation goes here
le = length(array);
fra = le/period;
array = [array, zeros(1, ceil(fra)*period-le)];
newarray = reshape(array', period, []);
end
然后,从脚本中删除该函数后,保存脚本并再次运行。这应该解决关于功能的问题。您可能有其他错误,但这应该处理您报告的错误。