I am having a problem plotting a 2D array via Plot3 function. How can I use the Rows and Columns as my X and Z axis?

1 次查看(过去 30 天)
I am having trouble using the Plot3 function.
I have a 2D array that I would like to plot in 3D by the dimensions of the Row # X value, Column # as my Z value and the actual cell values as my Y value.
The problem I'm having is that the input variables must all be the same size. This seems like it should be a pretty straight forward problem, but I haven't found any documentation or work around for this.
Here is the code I've written so far for this routine.
[rows,columns] = size(emg_recording)
ArrayX=(1:rows)' ArrayZ=(1:columns)'
Plot3(emg_recording)
Any help would be greatly appreciated.

回答(1 个)

Star Strider
Star Strider 2015-10-13
You have to create three column vectors from your data to use them with plot3, and they all have to be equal length. This replicates the row and column sizes to be equal to the number of elements in the array, and plots them. That’s the only way I can think of to do what you describe. It has the virtue of running, but I have no idea if it does what you want:
emg_recording = randi(9,6,8);
X = repmat([1:size(emg_recording,1)]', size(emg_recording,2), 1);
Z = repmat([1:size(emg_recording,2)]', size(emg_recording,1), 1);
Y = emg_recording(:);
figure(1)
plot3(X, Y, Z)
grid on
xlabel('Rows')
ylabel('Cell Value')
zlabel('Columns')

类别

Help CenterFile Exchange 中查找有关 Annotations 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by