How to fill a matrix with formula

4 views (last 30 days)
I want my output matrix to be a 4x5 matrix but you have given a 5x4 matrix as output.
y=zeros(1,20);
y(1)=0.7;
for i=2:20
y(i)=1.3*y(i-1)*(1-y(i-1));
end
y=reshape(y,[4,5]);
disp(y)
0.7000 0.2430 0.2335 0.2314 0.2309 0.2730 0.2391 0.2327 0.2312 0.2309 0.2580 0.2365 0.2321 0.2311 0.2308 0.2489 0.2348 0.2317 0.2310 0.2308
But my desired matrix:
y_answer =
0.7000 0.2730 0.2580 0.2489 0.2430
0.2391 0.2365 0.2348 0.2335 0.2327
0.2321 0.2317 0.2314 0.2312 0.2311
0.2310 0.2309 0.2309 0.2308 0.2308
I want to give y_answer as output.
In other words, from the first member to the fifth member of the y matrix, fill in the first row of the matrix and also the next rows of the matrix.
Can the code be changed to print the y_answer matrix in the output?

Accepted Answer

David Hill
David Hill on 10 Sep 2021
y=reshape(y,5,[])';

More Answers (0)

Categories

Find more on Dynamic System Models in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!