Comparing a value against a set of values
2 ビュー (過去 30 日間)
古いコメントを表示
I have a 1x1xn array of numbers that range from 0-255 (RGB), where n can be any number. Let's call it data.
I want to check if all the values of data are zero. If any of them are non-zero i want it to run a given command, and if they are all zero then I want it to not run the command
How can i do this?
0 件のコメント
回答 (2 件)
Raj
2019 年 9 月 10 日
編集済み: Raj
2019 年 9 月 10 日
A=rand(1,1,n) % Define your matrix here
B=nonzeros(A);
if isempty(B)
%%Do nothing
else
%%Run command here
end
2 件のコメント
Andrei Bobrov
2019 年 9 月 10 日
A=rand(1,1,n) % Define your matrix here
if all(A)
%%Run command here
end
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!