Assigning matrix rows to the same value and plotting
Ältere Kommentare anzeigen
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 Kommentar
Image Analyst
am 17 Feb. 2017
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.
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Pie Charts finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!