简体   繁体   English

在八度/ Matlab中绘制图表数组而不使用for循环

[英]Plotting an array of plots without using for loop in octave / matlab

How can I plot an array of plots all at once without using a for loop ? 如何在不使用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? 代码生成下面的图,但是它要求我使用for loop是否可以避免使用for循环?

情节

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)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM