How can I plot an array of plots all at once without using a for loop
?
Example code below:
clear all,clf reset,tic,clc
plot_array_x1=[-0.1732050807568878 -0.6767949192431123 -1.366025403784439
0.1732050807568877 0.176794919243112 0.366025403784438
6.123233995736766e-17 0.5000000000000001 1];
plot_array_y1=[-0.09999999999999995 0.186602540378444 0.366025403784439
-0.1000000000000001 -0.6794228634059948 -1.366025403784439
0.2 0.4928203230275509 0.9999999999999998];
for ii=1:3
plot(plot_array_x1(ii,:),plot_array_y1(ii,:))
hold on
end
The code produces the plot below but it requires me to use a for loop
is it possible to avoid using a for loop?
You're almost there. First, transpose the arrays and then remove the loop.
plot_array_x1=[-0.1732050807568878 -0.6767949192431123 -1.366025403784439;
0.1732050807568877 0.176794919243112 0.366025403784438;
6.123233995736766e-17 0.5000000000000001 1].';
plot_array_y1=[-0.09999999999999995 0.186602540378444 0.366025403784439;
-0.1000000000000001 -0.6794228634059948 -1.366025403784439;
0.2 0.4928203230275509 0.9999999999999998].';
figure(1)
plot(plot_array_x1,plot_array_y1)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.