Keep getting error message "Index exceeds array bounds."

I've looked over my code, and my teacher has looked over my code, but nobody cam figure out what's wrong. Here's my code:
% USER INPUT STATEMENTS
gender = menu('What is your gender?', 'Male', 'Female');
age = input('What is your age?');
weight = input('What is your weight in pounds?');
% This sections finds out essential information to compute the heart rate
% SENSOR INPUT STATEMENTS
hrate = dec2bin(88)
str = string(hrate);
% This section converts the sensor readig of the heart rate to a string
% DETERMINE AND DISPLAY CURRENT HEART RATE
chr = bin2dec(hrate);
disp(chr);
% This section displays the current heart rate in decimal
% COMPUTE MAXIMUM HEART RATE
if gender==1
MHR = (205.8-0.685*(age));
else
MHR = (206-0.88*(age));
end
% This section computes the maximum heart rate.
% CONDITIONAL STATEMENTS AND OUTPUT DISPLAY STATEMENTS
if chr < .6*MHR
disp('Below Level');
elseif .6*MHR <= chr < .7*MHR
disp('Weight Loss');
elseif .7*MHR <= chr < .8*MHR
disp('Cardio');
elseif .8*MHR <= chr < .9*MHR
disp(Anaerobic (Hardcore));
else
f= msgbox('lmao what you doin still alive you should be dead', 'lmao m8');
end

2 件のコメント

madhan ravi
madhan ravi 2018 年 10 月 8 日
Which line shows error?
Ethan Hawley
Ethan Hawley 2018 年 10 月 8 日
Which line shows error?
Line 29

サインインしてコメントする。

 採用された回答

madhan ravi
madhan ravi 2018 年 10 月 8 日

0 投票

>> COMMUNITY
What is your age?50
What is your weight in pounds?100
hrate =
'1011000'
88
Below Level
>>

1 件のコメント

madhan ravi
madhan ravi 2018 年 10 月 8 日
didn't get any error running your code

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File Exchange2-D and 3-D Plots についてさらに検索

製品

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by