if mod(t,2)==1 [task 1] else [task 2] end
The obvious way is to use a switch construct.
for i = 1:100 switch mod(i,5) case 0 case 1 case 2 case 3 case 4 end end
If you had more cases, I would probably try to be more creative.
Conditional statements enable you to select at run time which block of code to execute. The simplest conditional statement is an if
statement. For example:
% Generate a random number a = randi(100, 1); % If it is even, divide by 2 if rem(a, 2) == 0 disp('a is even') b = a/2; end
if
statements can include alternate choices, using the optional keywords elseif
or else
. For example:
a = randi(100, 1); if a < 30 disp('small') elseif a < 80 disp('medium') else disp('large') end
Matlabsolutions.com provides guaranteed satisfaction with a
commitment to complete the work within time. Combined with our meticulous work ethics and extensive domain
experience, We are the ideal partner for all your homework/assignment needs. We pledge to provide 24*7 support
to dissolve all your academic doubts. We are composed of 300+ esteemed Matlab and other experts who have been
empanelled after extensive research and quality check.
Matlabsolutions.com provides undivided attention to each Matlab
assignment order with a methodical approach to solution. Our network span is not restricted to US, UK and Australia rather extends to countries like Singapore, Canada and UAE. Our Matlab assignment help services
include Image Processing Assignments, Electrical Engineering Assignments, Matlab homework help, Matlab Research Paper help, Matlab Simulink help. Get your work
done at the best price in industry.