Error using .* matrix dimensions must agree
Show older comments
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])
Accepted Answer
More Answers (0)
Categories
Find more on Structures in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!