Clear Filters
Clear Filters

Info

This question is closed. Reopen it to edit or answer.

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

1 view (last 30 days)
IOANNIS KORACHAIS
IOANNIS KORACHAIS on 15 Nov 2020
Closed: MATLAB Answer Bot on 20 Aug 2021
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

Answers (1)

Ameer Hamza
Ameer Hamza on 15 Nov 2020
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

This question is closed.

Tags

Community Treasure Hunt

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

Start Hunting!