Defining a projection function

8 ビュー (過去 30 日間)
alpedhuez
alpedhuez 2018 年 5 月 12 日
コメント済み: Star Strider 2018 年 5 月 13 日
I have defined a function of three variables
function a = test(A,B,C)
a = A.*power(B,0.3).*power(C,0.7);
end
Now I want to define a function test2 that is a function test2 that is a single variable function of C with A=1 and B=10. Please advise.

採用された回答

Star Strider
Star Strider 2018 年 5 月 13 日
Try this:
test2 = @(C) test(1,10,C)
  2 件のコメント
alpedhuez
alpedhuez 2018 年 5 月 13 日
Thank you.
Star Strider
Star Strider 2018 年 5 月 13 日
As always, my pleasure.

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

その他の回答 (1 件)

Jan
Jan 2018 年 5 月 12 日
function a = test2(C)
A = 1;
B = 10;
a = A .* power(B, 0.3) .* power(C, 0.7);
end
Or easier:
function a = test2(C)
a = 1.99526231496888 .* power(C, 0.7);
end
I suggest, that you try to solve such questions by your own at first and to post the code. You can learn more from the suggestions for improvements than from code, which have been written by others from scratch.
  1 件のコメント
alpedhuez
alpedhuez 2018 年 5 月 13 日
The point is that, in your way, one has to rewrite the function whenever the values of A and B change. There is a reason that I ask these questions.

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

カテゴリ

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

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by