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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started