当前位置: 动力学知识库 > 问答 > 编程问答 >

arrays - Assign same length matrice/vector to different variables(MATLAB)

问题描述:

Length of variables lets call n which will create x{i]..to x{n} different variables

Now i can create those but i want all individual to have sin function with different values.

Let say t=0:1:5; length(t)=6 thus sin(t) will be matrice with length 6.

i tried a code below of course i should update the cell functions length but How can i make;

x{1}=sin(t),x{2}=sin(t) etc.All variables will have their own matrices.Whats your suggestions?

for i=1:n

for t=0:1:5;

x=cell(1);

x{i} = sin(t)

end

end

网友答案:

You are on the right track:

t = 0:1:5;
m = size(t,2);
x = cell(m,1);

for k = 1:m
x{k} = sin(t);
end

Each entry in the cell array will be a matrix.

分享给朋友:
您可能感兴趣的文章:
随机阅读: