A basic plotting problem in a for loop
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Christian
am 2 Feb. 2017
Kommentiert: Christian
am 2 Feb. 2017
Hello everybody,
I have a Problem which seems to be very stupid and I apologize for my question in advance!
I have a for loop to plot all of the results of a former loop. Now I would like to change the color of the plots to grey. Basically this is not a big deal if you have x and y for example. In my case I plot data1 vs data2. Both of them have the same size. If I use a colormap or something like 'color', [1 1 1] I always get the error that the vectors must be the same size. How can I fix this?!
for d=1:numel(Filename)
figure(1);
hold on
plot(Data_1(:,d), Data_2(:,d), 'Color', [1 1 1])
axis([-25 25 -20 25])
axis equal
end
Thank you!
Cheers
Christian
3 Kommentare
Stephen23
am 2 Feb. 2017
@Christian: please edit your question and give us the complete error message. This means all of the red text.
Akzeptierte Antwort
tafteh
am 2 Feb. 2017
Hi Christian,
(b) Unless the vectors Data_1(:,d) and Data_2(:,d) are not the same size, you should not get an error.
(c) using the argument 'Color' with the value of [1 1 1], results in plotting all the lines in white which is the same as the white background of plotting environment. You may want to change that :)
(d) I wrote the following code trying to mimic what you want to do:
first I generate two 2d matrices, a and b with same size:
if true
a = rand(3, 4); b = rand(3, 4);
end
and then I use your code to plot them:
if true
for d=1:size(a, 2) % mimic the numel(Filename) in your code.
figure(1);
hold on
plot(a(:,d), b(:,d), 'Color', [.1 .1 .1])
axis([-25 25 -20 25])
axis equal
end
end
it works for me. You may want to change the code based on your need.
cheers,
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Data Distribution Plots finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!