Array Elements and Equality Checks
Show older comments
Another really easy question from me, currently I have this code:
ADL = [52.0, 109.0, 55.8, 61.6, 18.4, 42.2, 18.2, 9.2, 5.6, 19.0, 49.6, 56.8];
PER = [131.4, 145.4, 129.0, 93.2, 4.0, 32.4, 0.0, 0.0, 0.0, 43.2, 23.2, 88.6];
Total = 0;
for i=12
if ADL(i) > PER(i)
disp('There was greater rainfall in Adelaide.')
elseif ADL(i) < PER(i)
disp('There was greater rainfall in Perth.')
elseif ADL(i) == PER(i)
disp('There was the same amount of rainfall in both cities.')
end
end
Yet it really doesn't like me doing it this way, how do I achieve the results I want in MATLAB?
3 Comments
Walter Roberson
on 5 Apr 2013
You did not indicate what results you want.
Image Analyst
on 5 Apr 2013
Regarding your last else, see the FAQ: http://matlab.wikia.com/wiki/FAQ#Why_is_0.3_-_0.2_-_0.1_.28or_similar.29_not_equal_to_zero.3F
Joseph Percsy
on 5 Apr 2013
Accepted Answer
More Answers (0)
Categories
Find more on Environment and Settings in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!