Matlab Matrix plot from a for-loop

1 回表示 (過去 30 日間)
Rotari Elena
Rotari Elena 2021 年 11 月 14 日
編集済み: KALYAN ACHARJYA 2021 年 11 月 14 日
Foto Hello everyone! I just need to make a matrix from my code. The x from 1 to 30 is actually my index. I need a proper y filled with zeros allong and only at i index filled with X Value. Hopefully you could understand me.
  3 件のコメント
Rotari Elena
Rotari Elena 2021 年 11 月 14 日
I have to made a matrix from x,y. My y is the Value from pi_approx from i=1 to 30. I need to fill the matrix whith zeros, said the prof.
KALYAN ACHARJYA
KALYAN ACHARJYA 2021 年 11 月 14 日
matrix=zeros(1,30);

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

回答 (1 件)

KALYAN ACHARJYA
KALYAN ACHARJYA 2021 年 11 月 14 日
pi_aprox=zeros(1,30);
n=6;
g2n=zeros(1,30);
U_neue=zeros(1,30);
g2n(1)=1;
for i=1:30
U_neue(i)=n*g2n(i);
pi_aprox(i)=U_neue(i)/2;
n=n*2;
g2n(i)=sqrt(2-sqrt(4-g2n(i)^2));
end
Please change as per requirements
  4 件のコメント
Rotari Elena
Rotari Elena 2021 年 11 月 14 日
pi_approx=[];
pi_approx=[];
n = 6;
g2n = 1;
for i = 1:30
i
U_neue = n * g2n;
pi_approx(i) = U_neue/2;
n = n * 2;
g2n = sqrt(2-sqrt(4-g2n^2));
end
x=1:1:30;
y=zeros(); *Hier I have to define a matrix from my pi_approx then plot it
plot(x,y)
KALYAN ACHARJYA
KALYAN ACHARJYA 2021 年 11 月 14 日
編集済み: KALYAN ACHARJYA 2021 年 11 月 14 日
x=1:1:30;
y=zeros(1,30);
plot(x,y);
Any sense?

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

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by