New variables in a loop

1 次查看(过去 30 天)
Ancalagon8
Ancalagon8 2019-12-25
Hello everyone! I'm facing some issues while trying to create new variables inside a loop. Can I load my data using a for loop while keeping first character (m)?
Thanks in advance!

回答(1 个)

KALYAN ACHARJYA
KALYAN ACHARJYA 2019-12-25
编辑:KALYAN ACHARJYA 2019-12-25
Considering the array or cell array is best way rather than assigning new variable in each iteration.
Fs=zeros(1,35);
for i=1:35
Fs(i)=L(i)/tmax(i); % assuming L and tmax both are scalars
end
% Assuming L and tmax both are scalars, if not then
Fs=cell(1,35);
for i=1:35
Fs{i}=L(i)/tmax(i);
end
  2 个评论
Ancalagon8
Ancalagon8 2019-12-25
i get message: Undefined function 'L' for input arguments of type 'double'.
KALYAN ACHARJYA
KALYAN ACHARJYA 2019-12-25
It's your code, I have just modified, what is L? Please define.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by