Question: Subject: Matlab %% How do I take the answer generated from a for loop and put it into an if statement? TNY =[31, 26, 30,

Subject: Matlab

%% How do I take the answer generated from a "for loop" and put it into an "if" statement?

TNY =[31, 26, 30, 33, 33, 39, 41, 41, 34, 33, 45, 42, 36, 39, 37, 45,43, 36, 41, 37, 32, 32, 35, 42, 38, 33, 40, 37, 36, 51, 50];

TAN =[37, 24, 28, 25, 21, 28, 46, 37, 36, 20, 24, 31, 34, 40, 43, 36, 34, 41, 42, 35, 38, 36, 35, 33, 42, 42, 37, 26, 20, 25, 31];

R = zeros(size(TNY));

for i = 1:length(TAN) R = R + (TNY==TAN(1,i)); end

R

================================================================================

R= [ 2 1 0 1 1 0 1 1 2 1 0 3..............]

I want to add 1 to any number that is not zero. How do I do that?

I've tried using

if R>0

Z=R+1

end

That doesn't work. Please help! Thanks!

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!