Assigning matrix rows to the same value and plotting
Afficher commentaires plus anciens
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 commentaire
Image Analyst
le 17 Fév 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.
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Pie Charts dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!