Carry out action dependent on specified values for input to lie between
古いコメントを表示
Sorry for the long title but I'm not too sure how I'd go about defining this in a small sentence.
I want a set of values to be chosen if the input falls within a range of values e.g. input = 135 so should fall between 90 < input <= 180.
Here's the code I'm using:
Alpha = input('Specify angle of rotation (0 - 360): ');
if Alpha > 360
Alpha = input('Specify angle of rotation (0 - 360: ');
elseif Alpha <= 0
Alpha = input('Specify angle of rotation (0 - 360: ');
elseif isempty(Alpha)
Alpha = input('Specify angle of rotation (0 - 360: ');
end
Alpha = Alpha*(pi/180)
a = sqrt(((cos(Alpha)^2))*((cos(Theta)^-2)-1))
b = sqrt((a^2)*((((cos(Alpha))^-2)-1)))
if 0 <= Alpha <= (90*(pi/180))
ZA = (2*(((cos(Theta))^-2)-1))^0.5;
ZB = a;
ZC = 0 ;
ZD = b;
end
if (90*(pi/180)) < Alpha <= (180*(pi/180))
ZA = b;
ZB = (2*(((cos(Theta))^-2)-1))^0.5;
ZC = a;
ZD = 0;
end
if (180*(pi/180)) < Alpha <= (270*(pi/180))
ZA = 0;
ZB = b;
ZC = (2*(((cos(Theta))^-2)-1))^0.5;
ZD = a;
end
if (270*(pi/180)) < Alpha < (360*(pi/180))
ZA = a;
ZB = 0;
ZC = b;
ZD = (2*(((cos(Theta))^-2)-1))^0.5;
end
At the moment it is assuming the conditions of the last if statement.
Basically how do I write 90 < Alpha <= 180 so that MATLAB will be able to process it?
I think I can get away with coding this using 'elseif' to reduce the size but I'd rather sort the problem out first.
I would be very grateful for help as this is for the final part of my dissertation which is due next week.
Thanks
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Mathematics についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!