フィルターのクリア

Assigning outputs variable names

17 ビュー (過去 30 日間)
Julia de Lange
Julia de Lange 2018 年 7 月 27 日
コメント済み: N/A 2018 年 7 月 30 日
I'm using the function findchangepts, which outputs 2 numerical values for me. I'd like to use these values and manipulate them further. How can I assign them separate variable names?
Thank you!
SamplNum = findchangepts(SensV, 'MaxNumChanges', 2);
% code
end
which gives
SamplNum =
21194
21609
So I'd like to assign both of those sample numbers a variable in order to manipulate them.
Thanks for your help, sorry if this is a simple question/answer, I'm new to Matlab!
  2 件のコメント
Star Strider
Star Strider 2018 年 7 月 27 日
‘How can I assign them separate variable names?’
Please don’t. That is not considered to be good programming practice.
Just use them as they are, and refer to them with the appropriate subscripts.
Stephen23
Stephen23 2018 年 7 月 27 日
If you really want to create two variables from the first two elements of the output vector, then use indexing:
SamplNum = findchangepts(SensV, 'MaxNumChanges', 2);
A = SamplNum(1)
B = SamplNum(2)
Note that this is not a general solution: the best solution would be to leave the data in the vector, where is easy to process, no matter how many elements it contains.
Basic MATLAB concepts, like how to use indexing and how to define variables, are explained in the introductory tutorials:

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

採用された回答

N/A
N/A 2018 年 7 月 27 日
I am not sure how the function is working, but you could simply do
Variable_1=SamplNum(1);
Variable_2=SamplNum(2);
or you do
[Variable_1, Variable_2] = findchangepts(SensV, 'MaxNumChanges', 2);
and adapt the code in-between.
  2 件のコメント
Stephen23
Stephen23 2018 年 7 月 27 日
編集済み: Stephen23 2018 年 7 月 27 日
@Philipp Heinirch: given that findchangepts only has one output argument, what do you expect this to do?:
[Variable_1, Variable_2] = findchangepts(...)
What happened when you tried this?
N/A
N/A 2018 年 7 月 30 日
Oh yeah, you are right. did not properly pay attention to this. My bad.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSignal Processing Toolbox についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by