Reputation: 19
I actually have data:
x y z
2 4 0,494949495
2 6 0,494949495
2 8 0,535353535
2 10 0,585858586
2 12 0,474747475
3 4 0,535353535
3 6 0,494949495
3 8 0,545454545
3 10 0,484848485
3 12 0,474747475
4 4 0,535353535
4 6 0,474747475
4 8 0,434343434
4 10 0,525252525
4 12 0,494949495
I want to plot these data as bar graph where z represent the height of the bars, but the problem is that I don't know how to deal with x and y axis, the value there are repeated and discontinuous and whenever I try to simply use bar3
I get the following error:
Error using matlab.graphics.axis.Axes/set While setting the 'YTick' property of 'Axes':
Value must be a vector of type single or double whose values increase
Error in bar3 (line 74)
set(cax,'ytick',y(:,1));
Upvotes: 0
Views: 197
Reputation:
Here is a way to plot the z values at each of the coordinates specified by the x and y columns.
xyzData=[2 4 0.494949495;
2 6 0.494949495;
2 8 0.535353535;
2 10 0.585858586;
2 12 0.474747475;
3 4 0.535353535;
3 6 0.494949495;
3 8 0.545454545;
3 10 0.484848485;
3 12 0.474747475;
4 4 0.535353535;
4 6 0.474747475;
4 8 0.434343434;
4 10 0.525252525;
4 12 0.494949495];
Y=NaN(xyzData(end,1),max(xyzData(:,2)));
Y(sub2ind(size(Y),xyzData(:,1),xyzData(:,2)))=xyzData(:,3);
figure;bar3(Y)
Output:
Upvotes: 1