Run a for loop for three different types of excitation

I need to run a for loop for three different scenarios. I tried this: -
etyp = 3 %number of excitation types
for i = 1:etyp
if i = 1
excitation = 'noise';
end
if (i = 2)
excitation = 'mls';
end
if (i = 3)
excitation = 'sweptsine';
end
end
but I get an error that I don't understand. Could anyone explain what's wrong with this code? Thanks

1 Comment

Tom's question
I need to run a for loop for three different scenarios. I tried this: -
etyp = 3 %number of excitation types
for i = 1:etyp
if i = 1
excitation = 'noise';
end
if (i = 2)
excitation = 'mls';
end
if (i = 3)
excitation = 'sweptsine';
end
end
but I get an error that I don't understand. Could anyone explain what's wrong with this code? Thanks

Sign in to comment.

 Accepted Answer

worked it out
equals signs for the ifs need to be doubles i.e. ==

More Answers (0)

Categories

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

Products

Tags

Asked:

Tom
on 19 Mar 2012

Community Treasure Hunt

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

Start Hunting!