Function and mask : from vector to line
古いコメントを表示
Hello,
I have a function and when calling it with vectors, it changes the orientation from vectors to lines ; I do not understand why ?
Do you have explanations ? I'd like to understand instead of just transposing...
My function :
function ratio = ratiocu(teta,bbb,rrr)
G1 = 0.000382806d0;
G2 = 1.32407d0;
G3 = 0.00167634d0;
G4 = 0.789953d0;
RRRcal = max(0.d0,bbb.*rhoc0(273.15d0,rrr)./rhoc0(teta,rrr));
mask1 = (RRRcal > 1);
ratio(mask1) = G1.*(RRRcal(mask1).^G2)./(1+G3.*(RRRcal(mask1).^G4))+1;
mask2 = (RRRcal > 40000);
ratio(mask2) = NaN;
mask3 = ~(mask1 | mask2);
ratio(mask3) = 1.d0;
end
teta and bbb are two vectors of same length, rrr is a number.
rhoc0 is a function rendering a vector.
I think this is because of the use of mask1...as the function gives a vector if i remove it.
Cheers.
FP
PS : you can test it by yourself by using this one for instance ;
function ratio = ratiocu(teta,bbb,rrr)
G1 = 0.000382806d0;
G2 = 1.32407d0;
G3 = 0.00167634d0;
G4 = 0.789953d0;
RRRcal = teta;
mask1 = (RRRcal > 1);
ratio(mask1) = G1.*(RRRcal(mask1).^G2)./(1+G3.*(RRRcal(mask1).^G4))+1;
mask2 = (RRRcal > 40000);
ratio(mask2) = NaN;
mask3 = ~(mask1 | mask2);
ratio(mask3) = 1.d0;
end
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Scripts についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!