why is my code giving me a parse error

1 回表示 (過去 30 日間)
zidan masood
zidan masood 2021 年 10 月 9 日
コメント済み: David Hill 2021 年 10 月 9 日
this is my code:
x=0.1;
beats=A(1,30);
for k=1:30
A=2x*(1-x);
x=A;
disp(A)
end
when i run this i get a parse error and A undefined
I am not familiar enough with MATLAB syntax to figure out what it even means, let alone how to fix it. Any ideas? Thank you!

回答 (1 件)

David Hill
David Hill 2021 年 10 月 9 日
編集済み: David Hill 2021 年 10 月 9 日
x=0.1;
%beats=A(1,30); There is no A defined and you are indexing into it!
for k=1:30
A(k)=2*x*(1-x); %need 2*, if you want to keep track of all iterations, index into A
x=A(end);
%disp(A)
end
disp(A);%display outside loop
  4 件のコメント
zidan masood
zidan masood 2021 年 10 月 9 日
this is my question
The heart beat rate has to be well regulated to provide enough oxygenated blood throughout the body and so depends on feedback with the body’s oxygen demand. A simple discrete model of heart beat regulation is given by:
xt+1 = kxt(1 - xt)
Here xt represents the normalised heart beat rate at time t recorded once per minute. That is, the normalisation involves dividing the actual hear rate in beats per minute by 80 beats per minute. The parameter k is a positive real number (hopefully) greater than 0
a) Write a MATLAB program using array operations to generate a table (with headings) of the normalised heart beat rate per minute starting at time t = 0 with the value of x0 entered by the user. Run your program with the maximum time set to 30 minutes. Show table and MATLAB code for x0 = 0.1 and k = 2
David Hill
David Hill 2021 年 10 月 9 日
I will get you started
HeartRate=.1;
Time=0;
t=table(Time,HeartRate);
%your loop
for k=1:30
t.Time(k)=k+1;
t.HeartRate(k)=
end

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

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by