display all the matrices present in the cell in one figure
8 views (last 30 days)
Show older comments
Hi. How can I display all the matrices in the "output" cell in one figure?
I have tried the following way but I display them in separate figures.
a=randi(100,157,2);
b=randi(200,189,2);
c=randi(300,183,2);
mat={a;b;c};
for i=1:size(mat,1)
if i==1
aaa(i)={[mat{i,1} repmat(100,size(mat{i,1},1),1)]};
elseif i==2
aaa(i)={[mat{i,1} repmat(150,size(mat{i,1},1),1)]};
elseif i==3
aaa(i)={[mat{i,1} repmat(200,size(mat{i,1},1),1)]};
end
end
output=aaa';
for kkk = 1:3
figure
plot3(output{kkk,1}(:,1), output{kkk,1}(:,2), output{kkk,1}(:,3),'k.','Markersize',15);
end
0 Comments
Accepted Answer
Voss
on 10 Dec 2022
figure
hold on
for kkk = 1:3
plot3(output{kkk,1}(:,1), output{kkk,1}(:,2), output{kkk,1}(:,3),'k.','Markersize',15);
end
0 Comments
More Answers (1)
Image Analyst
on 10 Dec 2022
Do you mean like this:
a=randi(100,157,2);
b=randi(200,189,2);
c=randi(300,183,2);
mat={a;b;c};
for i=1:size(mat,1)
if i==1
aaa(i)={[mat{i,1} repmat(100,size(mat{i,1},1),1)]};
elseif i==2
aaa(i)={[mat{i,1} repmat(150,size(mat{i,1},1),1)]};
elseif i==3
aaa(i)={[mat{i,1} repmat(200,size(mat{i,1},1),1)]};
end
end
output=aaa';
for k = 1:3
subplot(2, 2, k)
plot3(output{k,1}(:,1), output{k,1}(:,2), output{k,1}(:,3),'k.','Markersize',15);
grid on;
end
2 Comments
Image Analyst
on 10 Dec 2022
No. You misunderstand the definitions of figure, axes, and subplots. All those subplots ARE on one figure. Each subplot is a different axes. There are three axes (subplots) on one figure in my solution.
Since you did not understand the terminology your question was ambiguous. What you should have said was that you want all data to be plotted in a single axes (not figure). Then there would have been no uncertainty and people would have known what you meant.
In your accepted solution, all the markers are black so you can't tell which markers were from which set of data. You might want to change the marker color on every iteration, or maybe you don't want to - I don't know.
See Also
Categories
Find more on Annotations 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!