Any suggestion guys ?
How to put conditions to use data from command window
4 ビュー (過去 30 日間)
古いコメントを表示
Hello all,
I am using one code and in that code i received output from my program in the Command Window, and i would like to use that output in the same code to apply for condition
Speed= [400 : 100 : 1200] (in the code)
I would like to put the condition in this way
CD= 0.018 (Value directly in the code)
then use CD value in the below condition by using AB and BC value
If AB<CD>BC then successful at speed 10 ,
if above condition not satisfy then unsuccessful at speed 10
Similarly for other different speed as per code (Speed= [10 : 10 : 40] )
If AB<CD>BC then successful at Speed= [10 : 10 : 40]
if above condition not satisfy then unsuccessful at Speed= [10 : 10 : 40]
Thank you so much
7 件のコメント
Rik
2022 年 1 月 19 日
I don't need the entire code. The point is that there is some code that will print the two number to the command window. If you edit that part of the code so that it returns the two values as output arguments, you can do the conditional part next yourself.
Note that a<b>c means something else in Matlab than it does in normal Mathematics. You need (a<b) && (b>c) instead.
回答 (1 件)
Walter Roberson
2022 年 1 月 19 日
Assuming that CD is a scalar, and that AB and BC are column vectors and that Speed is a row vector:
statuses = ["unsuccessful", "successful"};
mask = AB < CD & AB > BC;
status = statuses(mask+1);
results = compose("%20.17f %20.17f (%s at %g speed)", AB, BC, statuses, Speed(:))
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Interactive Control and Callbacks についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!