フィルターのクリア

Vectorization of a function with system of ODE's

1 回表示 (過去 30 日間)
George Bashkatov
George Bashkatov 2021 年 4 月 17 日
回答済み: Walter Roberson 2021 年 4 月 17 日
I want to modify famp so that it accepts a vector of y values, and reshapes the values to 2 columns, and then computes values for each row, but I don't know how I can do it. Can you help me, please?
function dydz = famp(pa,N0,pe,se,k,y,z)
k=Par.N0*pa/(pa+pe);
dy1 = y(1).*(pa.*N0+(pa+pe).*(k.*y(1)./(y(1)+y(2)+1)));
dy2 = y(2).*se.*(k.*y(1)./(y(1)+y(2)+1));
dydz = [dy1; dy2];
What can you advice to read to understand vectorization and optimization in a whole? By the way I know about documentation, but it is not enough.

採用された回答

Walter Roberson
Walter Roberson 2021 年 4 月 17 日
function dydz = famp(pa,N0,pe,se,k,y,z)
y = reshape(y, [], 2);
k=Par.N0*pa/(pa+pe);
dy1 = y(:,1).*(pa.*N0+(pa+pe).*(k.*y(:,1)./(y(:,1)+y(:,2)+1)));
dy2 = y(:,2).*se.*(k.*y(:,1)./(y(:,1)+y(:,2)+1));
dydz = reshape([dy1, dy2],[],1);

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by