Can't put all values from a for loop to a vector

I want to put all the values from x that come out from the loop but it only lets me put 2 values. What am i doing wrong?
function [x,y]= mems(k)
x0 = 0;
x = x0;
for i = 1:
x1 = x;
y1 = 0.3 .* x1;
x(i) = 1 + y1 - 1.4 .* x1 .^ 2;
end
end

1 件のコメント

IOANNIS KORACHAIS
IOANNIS KORACHAIS 2020 年 11 月 15 日
i = 1:k ****

回答 (1 件)

Ameer Hamza
Ameer Hamza 2020 年 11 月 15 日

0 投票

Are you trying to do something like this?
x = mems(5)
function [x]= mems(k)
x0 = 0;
x = x0;
for i = 1:k
x1 = x(i);
y1 = 0.3 .* x1;
x(i+1) = 1 + y1 - 1.4 .* x1 .^ 2;
end
end

この質問は閉じられています。

タグ

質問済み:

2020 年 11 月 15 日

閉鎖済み:

2021 年 8 月 20 日

Community Treasure Hunt

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

Start Hunting!

Translated by