unable to plot this equation

1 回表示 (過去 30 日間)
shiv gaur
shiv gaur 2022 年 2 月 23 日
編集済み: Arif Hoq 2022 年 2 月 23 日
t=1:20;
a(1)=1;
b(1)=1;
c(1)=1;
I=0.5;
a=1;b=3;
c=1;
d=5
r=0.0001;
s=4;
xr=-1.6
sumx=0;
sumy=0;
sumz=0;
for i=1:20
a(i+1)=(-a*a(i).^3+b*a(i).^2+b(i)-c(i)+I)/(i+1)
b(i+1)=(c-d*a(i)^2-b(i))/(i+1);
c(i+1)=r*((s*(a(i)-xr)-c(i)))/(i+1);
sumx=sumx+a(i)*t.^i;
sumy=sumy+b(i).*t.^i;
sumz=sumz+c(i).*t.^i;
end
plot(t,sumx)
  4 件のコメント
Arif Hoq
Arif Hoq 2022 年 2 月 23 日
so what is the value of a ? it can not be a scalar.here a =1. it should be a vector or matrix
shiv gaur
shiv gaur 2022 年 2 月 23 日
so a is the vector you can take a is the parameter scalar a(i) is the vector so you can take replacement as a=m
for simplicity edit program is here
t=1:20;
a(1)=1;
b(1)=1;
c(1)=1;
I=0.5;
m=1;b=3;
c=1;
d=5
r=0.0001;
s=4;
xr=-1.6
sumx=0;
sumy=0;
sumz=0;
for i=1:20
a(i+1)=(-m*a(i).^3+b*a(i).^2+b(i)-c(i)+I)/(i+1)
b(i+1)=(c-d*a(i)^2-b(i))/(i+1);
c(i+1)=r*((s*(a(i)-xr)-c(i)))/(i+1);
sumx=sumx+a(i)*t.^i;
sumy=sumy+b(i).*t.^i;
sumz=sumz+c(i).*t.^i;
end
plot(t,sumx)

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

回答 (1 件)

Arif Hoq
Arif Hoq 2022 年 2 月 23 日
i have considered the variable with random number
t=1:20;
I=0.5;
a=randi(20,1,20);
b=randi(30,1,20);
c=randi(30,1,20);
m=1;
d=5;
r=0.0001;
s=4;
xr=-1.6;
sumx=0;
sumy=0;
sumz=0;
C=cell(1,3);
for i=1:20
C{i,1}=(-m*a(i).^3+b*a(i).^2+b(i)-c(i)+I)/(i+1);
C{i,2}=(c-d*a(i)^2-b(i))/(i+1);
C{i,3}=r*((s*(a(i)-xr)-c(i)))/(i+1);
sumx=sumx+C{i,1}.*t.^i;
sumy=sumy+C{i,2}.*t.^i;
sumz=sumz+C{i,3}.*t.^i;
end
plot(t,sumx)
  2 件のコメント
shiv gaur
shiv gaur 2022 年 2 月 23 日
so you are req to plot as same value not random value
Arif Hoq
Arif Hoq 2022 年 2 月 23 日
編集済み: Arif Hoq 2022 年 2 月 23 日
do you mean?
a =ones(1,20,1)
a = 1×20
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
b=repmat([2 2 2 2 2],1,4)
b = 1×20
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
c=repmat([3 3 3 3 3],1,4)
c = 1×20
3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3

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

カテゴリ

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

タグ

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by