필터 지우기
필터 지우기

How to plot cell array data?

조회 수: 1 (최근 30일)
Cynthia Dickerson
Cynthia Dickerson 2016년 8월 11일
댓글: Cynthia Dickerson 2016년 8월 19일
I'm trying to plot the contents of a cell array (RSD_c{v}) composed of 5 32x3 double matrices. I want each column to be the X,Y,and Z variable, respectively.
if true
%Plot bias vs. B vs. v
%bias, B, and v contained in RSD_c(:,1), RSD_c(:,2), and RSD_c(:,5), respectively
figure;hold on;
cellfun(@scatter3,RSD_c(:,1),RSD_c(:,2),RSD_c(:,3));
end
When I run the above code,I get the error, "??? Error using ==> scatter3 at 63 X, Y and Z must be vectors of the same length."
What am I doing wrong? How do I fix this?

답변 (1개)

Adam
Adam 2016년 8월 11일
cellfun( @(x) scatter3( x(:,1), x(:,2), x(:,3) ), RSD_c )
should work, though I haven't double-checked the syntax in Matlab itself.
doc cellfun
should give examples of this syntax for calling.
  댓글 수: 1
Cynthia Dickerson
Cynthia Dickerson 2016년 8월 19일
Thanks. I used the following code:
if true
figure;hold on;
cellfun( @(x) scatter3( x(:,3), x(:,4), x(:,5) ), RSD_c );
title('Relationship Between Relative Standard Deviation, Bootstrap Replicates, and Dimension')
xlabel('Bootstrap Replicates') % x-axis label
ylabel('Relative Standard Deviation') % y-axis label
zlabel('Dimensions') % z-axis label
end
It does create a plot, and tracing the points shows that they have x, y, and z coordinates. However, the graph is 2-dimensional, with the points color-coded by z-coordinate.
Does anybody know how to fix this?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Scatter Plots에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by