calling for the same data based on a result
情報
この質問は閉じられています。 編集または回答するには再度開いてください。
古いコメントを表示
- data1 = a
- data2 = b
- x = a*b;
- c = a;
- for i = 0
- if c > 5
- c = 1
- else
- c = 0
- end
I want to write a code such that if c = 1 it will take data1. I am trying to write a code but I am getting a confused how to return to data1 if c = 1 is the result
6 件のコメント
Bob Thompson
2018 年 10 月 31 日
編集済み: Bob Thompson
2018 年 10 月 31 日
Is there a more complete version of your code? I'm confused how c will ever be anything besides 'a'.
Also, what do you mean by 'take' data1. Do you want to set c equivalent to data1, or are you looking to display the value? Is there some other operation that you would like to complete with data1 as an input?
Panda Girl
2018 年 10 月 31 日
Panda Girl
2018 年 10 月 31 日
編集済み: Image Analyst
2018 年 10 月 31 日
Image Analyst
2018 年 10 月 31 日
"then" is not a word used in MATLAB.
Also, the format for a for loop is to have a starting and stopping value - you have just a single value or i, j, or l equal to zero so the for loop only executes once.
Panda Girl
2018 年 10 月 31 日
Bob Thompson
2018 年 10 月 31 日
編集済み: Bob Thompson
2018 年 10 月 31 日
I think it's possible for Matlab to execute a for loop only once, it's just redundant because you can just execute the commands once without the loop.
For your if statements your conditions seem to be set up right, I would just replace the count_tag0 = 1 type lines with the execution of your next operation with sc1/sc2/sc0 as an input. Defining count_tag to be 1 is a bit redundant.
if count_tag0 > 8;
result = operation(sc0);
end
if count_tag1 > 8;
result = operation(sc1);
end
if count_tag2 > 8;
result = operation(sc2);
end
回答 (0 件)
この質問は閉じられています。
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!