Loop Command and plotting

5 ビュー (過去 30 日間)
Derek Bindbeutel
Derek Bindbeutel 2016 年 4 月 16 日
コメント済み: Satyajeet Sasmal 2016 年 4 月 18 日
Ok so I have this script file that will give me 20 x values but only one y value. I need to have 20 of both and plot them accordingly. (x1,y1),(x2,y2),......(x20,y20). I know I'm missing some kind of loop statement but I'm not sure what it is. Any help would be appreciated. Thanks in advance.
clear all;
clc
format compact;
n=20;
x=1:n;
t=60;
for F=('female')
a= 21;
w= 115;
h= randi([153 175]);
F= ((((a*0.074)-(w*0.05741)+(h*.4472)-20.4022)*t)/4.184);
end
display(F);
for M=('male')
a=22;
w=258;
h=randi([163 184]);
M= ((((a*.2017)-(w*0.09036)+(h*.6309)-55.0969)*t)/4.184);
end
display(M);
figure;
plot(x,M,'*r',x,F,'k*');
title 'Calories Burned in 60 mins';
xlabel 'Days';
ylabel 'Calories';
  2 件のコメント
Azzi Abdelmalek
Azzi Abdelmalek 2016 年 4 月 16 日
This is not clear, can you post an example?
Satyajeet Sasmal
Satyajeet Sasmal 2016 年 4 月 18 日
I do not understand the workflow. Why do you need 20 values of x when you are only generating 4 values for 'male' and 6 values for 'female'? But if you can save the value of F for 'female', you can save 6 values for female and 4 for male. Something like this:
for F=('female')
a= 21;
w= 115;
h= randi([153 175]);
F= ((((a*0.074)-(w*0.05741)+(h*.4472)-20.4022)*t)/4.184);
f(k) = F;
k = k + 1;
end

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

回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by