How to suppress all the outputs during assignment of multiple variables with the same value? [To improve presentation]
4 views (last 30 days)
Show older comments
Sachin Motwani
on 20 Aug 2020
Commented: Bruno Luong
on 21 Aug 2020
X = imread('parrot.jpg');
R,G,B = X;
I am trying to assign multiple variables (here; R, G & B) with the same value (i.e., X). A semicolon is put to suppress the resulting matrix outputs. However, the matrix of R and G are not getting supressed; only the B one's is.
How should I code that all the outputs are getting suppressed?
0 Comments
Accepted Answer
Sachin Motwani
on 21 Aug 2020
1 Comment
Bruno Luong
on 21 Aug 2020
This will be equivalent to assign
R = X;
G = X;
B = X;
I don't think thiis is OP's intention.
More Answers (1)
Bruno Luong
on 21 Aug 2020
X = imread('parrot.jpg');
X = num2cell(X,[1 2]);
[R,G,B] = deal(X{:});
Or simply
X = imread('parrot.jpg');
R = X(:,:,1);
G = X(:,:,2);
B = X(:,:,3);
0 Comments
See Also
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!