Info

この質問は閉じられています。 編集または回答するには再度開いてください。

I need to be able to input a vector, either as a vector, or as a variable name, to a function.

1 回表示 (過去 30 日間)
DJ V
DJ V 2016 年 11 月 27 日
閉鎖済み: Stephen23 2016 年 11 月 27 日
I need to be able to use a vector as an input to a function, but it can be either in vector form or as a variable name: here c0 and x are scalars. C and [1 2 3] are the vectors.
q = pmath(c0, C, x) or q = pmath(c0,[1 2 3],x)
either way needs to work. Can this be done? finally I need to be able to produce
p=
  1 件のコメント
Stephen23
Stephen23 2016 年 11 月 27 日
Duplicate:
https://www.mathworks.com/matlabcentral/answers/314196-i-need-to-be-able-to-use-a-vector-as-an-input-to-a-function-either-as-a-variable-or-in-form-1-2

回答 (1 件)

Image Analyst
Image Analyst 2016 年 11 月 27 日
Of course. This is one of the most basic functions of MATLAB. You will need to learn how to call functions
To call:
q = pmath(c0, C, x)
To declare / define the function:
function q = pmath(c0, C, x)
% code
Again, you can pass in variables or actual numbers.

この質問は閉じられています。

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by