New variables in a loop

1 view (last 30 days)
Ancalagon8
Ancalagon8 on 25 Dec 2019
Edited: Ancalagon8 on 6 Jan 2025
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!

Answers (1)

KALYAN ACHARJYA
KALYAN ACHARJYA on 25 Dec 2019
Edited: KALYAN ACHARJYA on 25 Dec 2019
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 Comments
Ancalagon8
Ancalagon8 on 25 Dec 2019
i get message: Undefined function 'L' for input arguments of type 'double'.
KALYAN ACHARJYA
KALYAN ACHARJYA on 25 Dec 2019
It's your code, I have just modified, what is L? Please define.

Sign in to comment.

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!