Set of values and Conditional Logic

I am comparing two data sets through some conditional if and else if statements. The problem I'm experiencing is that the conditional statements only executes if the statement is exclusively true, otherwise it does nothing. For some of the values, the first conditional statement will be true while for other values the next statement might be true. How do I create a loop that executes the correct statement for each value???
for n = Y1(1:24)
for n1 = Y2
if n >= n1
t= interp1(Y1,(xlsread(Stuff,'B1:B76')),y1(8:94),'nearest');
fprintf('F = %d \n',t)
elseif n < n1
t1 = interp1(Y3,xlsread(Stuff,'F1:F35'),y2(8:103),'nearest');
fprintf('%d \n',t1)
else
t = 0
t1 = 0
end
end
end

1 Comment

You really should do the xlsread()s before the loops for efficiency.
Are Y1 and Y2 row vectors or column vectors? (It makes a difference for how the for operates)

Sign in to comment.

Answers (0)

Categories

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

Asked:

on 13 Sep 2016

Commented:

on 13 Sep 2016

Community Treasure Hunt

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

Start Hunting!