A = 1 2 3 4 5 6 7 8 9 10 11 12 --------------t=i*ti时刻 i=0 即0时刻
2 3 4 5 6 7 8 9 10 11 12 13 --------------t=i*ti时刻 i=1 即ti时刻
3 4 5 6 7 8 9 10 11 12 13 14 --------------t=i*ti时刻 i=2 即2ti时刻
4 5 6 7 8 9 10 11 12 13 14 15 --------------t=i*ti时刻 i=3 即3ti时刻
一行代表一个时刻
每行有6个点 12个数字分表是各点的x,y
例如第一行就是:0时刻的x1,y1,x2,y2,x3,y3,x4,y4,x5,y5,x6,y6
现在我想画出各个点的x(t) y(t)
写出了下面的代码 现在问题是
1.坐标轴标签和图像题目中显示随着j变化的 ylabel('y_j/mm'); title('plot of y_j(t)');以及 ylabel('y_j/mm'); title('plot of y_j(t)');
经过提示我知道要用到字符串数组的,num2str,但是我试了一下,ylabel('eval(strcat('y_',num2str(j),'/mm'))'); 不对,嘿嘿,不知道正确的应该怎么编写
2.保存图像,我想都保存下来 saveas(figure(j),'y_j(t)','png') saveas(figure(j+6),'x_j(t)','png') 但是只保存了2个
figure(j);是1到6是各点的y(t) figure(j+6);7到12是各点的x(t) 就是我想要都保存下来 saveas这儿应该怎么编写 估计还是和1的问题是一样的吧
3.图画出来,我看了一下,虽然出了12个图,6个y(t)图,6个x(t)图,但是都是第一点的 可能循环没循环出来吧
望大家帮帮忙 谢啦
A=[1,2,3,4,5,6,7,8,9,10,11,12;2,3,4,5,6,7,8,9,10,11,12,13;3,4,5,6,7,8,9,10,11,12,13,14;4,5,6,7,8,9,10,11,12,13,14,15;]
for j=1:1:6
k=1;ti=0.01;
for i=0:1:(size(A,1)-1)
figure(j);
t=i*ti;
y=A(i+1,k+1);
plot(t,y,'+');
xlabel('time/s');
ylabel('y_j/mm');
title('plot of y_j(t)');
hold on
figure(j+6);
x=A(i+1,k);
plot(t,x,'.')
xlabel('time/s')
ylabel('x_j/mm')
title('Plot of x_j(t)')
hold on
end
saveas(figure(j),'y_j(t)','png')
saveas(figure(j+6),'x_j(t)','png')
k=k+1;
end
[本帖最后由 懒猴阿呆 于 2012-1-14 10:43 编辑]