Too many dimensions error msg in figure
Show older comments
I get the message "Error using plot Data may not have more than 2 dimensions" when running the follwoing commands:
Alder = {'<20', '2029','3039','4049','5059','6069','>70', 'all'};
Vars = {AlG, AlR, AlI, AlDI, AlBV};
Vars2 = {'AlG', 'AlR', 'AlI', 'AlDI', 'AlBV'};
Aar = {'2011', '2012', '2013_1', '2014_1', '2014_s2', '2014_s5'};
n = length(Vars);
nAar = length(Aar);
nAl = length(Alder);
numberOfColors = nAl;
myColorMap = lines(numberOfColors);
for iVars = 1:n;
aVars = Vars{iVars};
figure,title(Vars2{iVars});
hold on
for iAl = 1:nAl
plot(aVars(11,iAl,:), 'color', myColorMap((iAl), :));
set(gca, 'XTickLabel',Aar)
legend((Alder),'location','NE','FontSize',10);
end
hold off
end
plot(aVars(11,1,:), 'color', myColorMap((iAl), :));
All matrices inn "Vars" is 11x8x6 matrices. I don't understand why the above commands fails, since almost the same commands work in this case below. The only difference is that in the above script I have "Alder" on the x-axis and in the below script I have "Aar" on the x-axis.
Alder = {'<20', '2029','3039','4049','5059','6069','>70', 'all'};
Vars = {gjG, gjR, gjI, gjDI, gjBV, GtoDI, GtoBV, RtoDIplusR, ItoG, RtoG, GtoI};
Vars2 = {'gjG', 'gjR', 'gjI', 'gjDI', 'gjBV', 'GtoDI', 'GtoBV', 'RtoDIplusR', 'ItoG', 'RtoG', 'GtoI'};
Aar = {'2011', '2012', '2013_1', '2014_1', '2014_s2', '2014_s5'};
n = length(Vars);
nAar = length(Aar);
numberOfColors = 6;
myColorMap = lines(numberOfColors);
for iVars = 1:n;
aVars = Vars{iVars};
figure,title(Vars2{iVars});
hold on
for iAar = 1:nAar
plot(aVars(11,:,iAar), 'color', myColorMap((iAar), :));
set(gca, 'XTickLabel',Alder)
legend((Aar),'location','NE','FontSize',10);
end
hold off
end
Accepted Answer
More Answers (0)
Categories
Find more on Vector Volume Data 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!