Loop Command and plotting

4 次查看(过去 30 天)
Derek Bindbeutel
Derek Bindbeutel 2016-4-16
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 CenterFile Exchange 中查找有关 Annotations 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by