フィルターのクリア

Calling a Function with multiple outputs

15 ビュー (過去 30 日間)
Mizo Amreya
Mizo Amreya 2020 年 7 月 10 日
コメント済み: Mizo Amreya 2020 年 7 月 10 日
Hi,
I'm trying to call a function with multiple outputs/inputs into my code.
The problelm I'm encountering is the function is returning the same value for all 3 outputs despite having different inputs and formulae.
Please advise how can I solve this issue.
This is my function:
function [lamdaT,lamdaW,lamdaO] = mobility_ratio(krw,kro,muiw,muio)
% Calculation of Mobility Ratio
% Water Mobility Ratio
lamdaW = krw/muiw;
% Water Mobility Ratio
lamdaO = kro/muio;
% Total Mobility Ratio
lamdaT = lamdaW + lamdaO;
end
This is how I'm calling it into my code:
for t=1:50
for i=1:50
lamdaW(i,t)=mobility_ratio(krw(i,t),kro(i,t),muiw,muio);
lamdaO(i,t)=mobility_ratio(krw(i,t),kro(i,t),muiw,muio);
lamdaT(i,t)=mobility_ratio(krw(i,t),kro(i,t),muiw,muio);
end
end

採用された回答

Arthur Roué
Arthur Roué 2020 年 7 月 10 日
編集済み: Arthur Roué 2020 年 7 月 10 日
You should call you function this way :
for t=1:50
for i=1:50
[lamdaT(i,t), lamdaW(i,t), lamdaO(i,t)] = mobility_ratio(krw(i,t),kro(i,t),muiw,muio);
end
end
In your for loop, you call the function three time with the same inputs and you capture only the 1st output, which is the same.
  1 件のコメント
Mizo Amreya
Mizo Amreya 2020 年 7 月 10 日
Thank you, I see your logic.
It worked. I appreciated it.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by