Reputation: 523
I have two surfaces in MATLAB that I would like to plot side-by-side in the same window.
After searching on Mathworks, it seems like the hold command is what I needed, so I tried this (as well as several variants):
surf(1:200,1:200,autism_mat(1:200,1:200));
title('Autism Group')
hold on;
surf(1:200,1:200,control_mat(1:200,1:200));
title('Control Group')
But the last plot just replaces the first. It seems that I'm missing something simple, I didn't think it would be difficult to do this.
Upvotes: 0
Views: 3098
Reputation: 238487
Just add offset to x or y coordinate in the second surface.
surf(1:200,1:200,autism_mat(1:200,1:200));
title('Autism Group')
hold on;
surf([1:200] + 250,1:200,control_mat(1:200,1:200));
title('Control Group')
Or you can plot them as subplots:
figure;
subplot(1,2,1);
lines = surf(1:200,1:200,rand(200,200));
title('Autism Group')
subplot(1,2,2);
surf(1:200,1:200,rand(200,200));
title('Control Group')
Upvotes: 2