What wrong with this?

24 ビュー (過去 30 日間)
Darkhan Sheldebayev
Darkhan Sheldebayev 2019 年 11 月 7 日
回答済み: Stijn Haenen 2019 年 11 月 7 日
clear ;
clc;
velocity = str2double(input('Enter your constant velocity for v: '));
while isnan(velocity) % If your input is not a number
velocity = str2double(input('Your value is not a number.Please input your velocity for v:','s')); % Enter new input for c
end
while velocity == 0
disp('Your velocity must not be zero');
velocity = str2double(input('Enter enter true value of constant velocity for v: '));
while isnan(velocity) % If your input is not a number
velocity = str2double(input('Your value is not a number.Please input your velocity for v:','s')); % Enter new input for c
end
end
Height = str2double(input('Enter your height to explorers for H: '));
while isnan(Height) % If your input is not a number
Height = str2double(input('Your value is not a number.Please input your height for H:','s')); % Enter new input for c
end
while Height == 0
disp('Your height must not be zero');
Height = str2double(input('Enter true value of height for H: '));
while isnan(Height) % If your input is not a number
Height = str2double(input('Your value is not a number.Please input your height for H:','s')); % Enter new input for c
end
end
v = velocity;
H = Height;
disp(' g is a gravitational acceleration which is 9.81 m/s');
g = 9.81;
t = sqrt((2*H)/g);
disp(t);
S =v*t;
disp(S);

回答 (1 件)

Stijn Haenen
Stijn Haenen 2019 年 11 月 7 日
you dont need 'str2double' if you ask for an input which should be a number

カテゴリ

Help Center および File ExchangeDictionaries についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by