Assigning matrix rows to the same value and plotting
显示 更早的评论
Hi! So I'm relatively new to coding, so I'm sure there is a simple answer for this. Anyways, here is my problem:
I have a matrix, say x = [1 2 3;4 5 6;7 8 9], and each row corresponds to a different value, say u = -3,0,3. I'm trying to generate a plot like (-3, [1 2 3]), (0,[4 5 6]), (3, [7 8 9]). But I'm having some trouble.
My idea was to generate a matrix of two columns using the following code:
plot_data = [];
for i=1:length(u)
for m = 1:length(x)
x1 = u(i)
y1 = x(i,m)
plot_data(m ,1) = x1
plot_data(m ,2) = y1
end
end
I'm sure I'm doing this in a very roundabout way, and the code I wrote doesn't work correctly. Can anyone give me some help?
1 个评论
Image Analyst
2017-2-17
I don't know what "a plot like (-3, [1 2 3]), (0,[4 5 6]), (3, [7 8 9])" looks like. Mock up something in Photoshop, or draw something and take a photo or it or scan it in, and post a picture of it.
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Pie Charts 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!