Error using .* matrix dimensions must agree
显示 更早的评论
I am plotting polar plots of my data. The first polar plot plots fine. The second plot plots fine if I run it on its own but if I run it after the first plot then I receive the error: Error using .*
I can see that the index (ind) that is being used changed from 48 to 26 but I do not understand why.
I would appreciate help in getting my matrix dimensions to agree.
%%Import data from spreadsheet
[filename,pathname]=uigetfile('*.xlsx','Select the file');
data = xlsread(filename);
% Allocate imported array to column variable names
Dir = data(:,1);
Max = data(:,2);
Mean = data(:,3);
Count = data(:,4);
TotFlow = data(:,5);
% Clear temporary variables
clearvars data raw;
%%Max
plotdata = Max;
A=sortrows([Dir,plotdata]); % sorts into ascending order
Dir=A(:,1).*pi./180; % converts to radians from degrees
plotdata=A(:,2);
New=[];
for i=1:size(A(:,2),1)
New=[New;plotdata(i);plotdata(i)];
end
% plot the data
figure;
[t,r]=rose(Dir,720);
ind=find(r);
r(ind)=r(ind).*New';
p = polar(t,r,'b');
view([90 -90])
%patch('FaceColor','none');
%%Mean
clear A t r p i ind New plotdata
plotdata = Mean;
A=sortrows([Dir,plotdata]); % sorts into ascending order
Dir=A(:,1).*pi./180; % converts to radians from degrees
plotdata=A(:,2);
New=[];
for i=1:size(A(:,2),1)
New=[New;plotdata(i);plotdata(i)];
end
% plot the data
figure;
[t,r]=rose(Dir,720);
ind=find(r);
r(ind)=r(ind).*New';
p = polar(t,r,'g');
view([90 -90])
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Structures 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!