display all the matrices present in the cell in one figure
4 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Voss
2022-12-10
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 个评论
更多回答(1 个)
Image Analyst
2022-12-10
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 个评论
Image Analyst
2022-12-10
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.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Line Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!