Passing array as an input argument

101 ビュー (過去 30 日間)
Mayank Nautiyal
Mayank Nautiyal 2019 年 10 月 6 日
コメント済み: Mayank Nautiyal 2019 年 10 月 7 日
I want to pass an array [p1 p2 p3] in the function "arithmetic_decoding" as an input.
function arithmetic_decoding(tag,n,[p1,p2,p3]) % this shows error "Unbalanced or unexpected parenthesis or bracket"
Please help?
%p1=0.4;
%p2=0.5;
%p3=0.1;

採用された回答

the cyclist
the cyclist 2019 年 10 月 6 日
Is that how you are calling the function, or is it the function header (inside the function file itself)?
If that is how you are calling the function, you don't want the word function there. Instead, use just
arithmetic_decoding(tag,n,[p1,p2,p3])
If that is the function header, then you'll need to do something like
function arithmetic_decoding(tag,n,p)
and then parse the p1,p2,p3 inside the function itself.
  3 件のコメント
per isakson
per isakson 2019 年 10 月 7 日
編集済み: per isakson 2019 年 10 月 7 日
Why do you want to do this in the first place?
You'll need something like this
function arithmetic_decoding(tag,n,p)
p1 = p(1);
p2 = p(2);
p3 = p(3);
end
Mayank Nautiyal
Mayank Nautiyal 2019 年 10 月 7 日
Thanks it worked.

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

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by