Plotting the radius of a sphere

2 Ansichten (letzte 30 Tage)
Ogen
Ogen am 13 Mär. 2016
Beantwortet: Walter Roberson am 13 Mär. 2016
Hello all, I have produced an animation of a fireball using the comet3 function (see code and question below)
kt = 'Please enter the yield in kilotonnes you wish to test: ';
kt = input(kt);
Fireball = 'Your fireball volume for your chosen yield: ';
if (kt<=1);
fireball_radius1 = 60;
elseif(kt<=2>=1);
fireball_radius2 = 80;
elseif(kt<=3>=2);
fireball_radius3 = 90;
end
z = linspace(-1,1,5000);
r = sqrt(1-z.^2);
t = linspace(0,150*pi,5000);
x = r.*cos(t);
y = r.*sin(t);
comet3(x,y,z)
I want the fireball radius to be 60, 80 or 90 dependant on which section the yield the user inputs falls into. How do I re-call the radius values? So for example if the user inputs a value of 1.5Kt the radius of the fireball needs to be 80Km. How is this recalled to plot that value. Thanks

Antworten (1)

Walter Roberson
Walter Roberson am 13 Mär. 2016
kt<=2>=1 means the same as ((kt<=2)>=1) . The first part of it will evaluate to 0 (false) or 1 (true). You are then testing whether 0 >= 1 (which is false) or 1 >= 1 (which is true), so this test is the same test as kt<=2 .
MATLAB does not have any range comparison operators. Very few programming languages do.

Kategorien

Mehr zu Lighting, Transparency, and Shading finden Sie in Help Center und File Exchange

Tags

Noch keine Tags eingegeben.

Community Treasure Hunt

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

Start Hunting!

Translated by