How to fill a matrix with formula

4 ビュー (過去 30 日間)
aziz monavar
aziz monavar 2021 年 9 月 10 日
回答済み: David Hill 2021 年 9 月 10 日
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?

採用された回答

David Hill
David Hill 2021 年 9 月 10 日
y=reshape(y,5,[])';

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDynamic System Models についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by