# how to merge 2D and 3D plots with desired positioning

5 visualizzazioni (ultimi 30 giorni)
Davit Hakobyan il 1 Lug 2013
Hi everybody. I have one 3d cylinder and one 2d circle. I want to plot them together the circle being the fundamental layer of cylinder at z=0. Thank's in advance. Here so far what I have, I can plot them separately. clear all; clc; close all;
A = P(:,:,2); %select one channel
D = double(A(:,:)); %make it double
k = size(D,2); %the z direction
t = 1:k;
theta=linspace(0,2*pi,size(D,1));
[time,angle]= meshgrid(t,theta);
x = r*cos(angle);
y = r*sin(angle);
c = D(:,:);
figure(1)
surface(x,y,time,c)% making cylinder
set(gcf,'Position',[0 0 400 700 ]);
view([-164,-26])
sz=size(A); x2=633; y2=529; % center of region
[x1grid, y1grid] = meshgrid(1:sz(2), 1:sz(1));
x1 = x1grid - x2; % offset the origin y1 = y1grid - y2;
circlemask = x1.^2 + y1.^2 > r.^2;
% Use the mask to select part of the image
hold all
figure(2) imagesc(circle_image);% circular part
##### 0 CommentiMostra -2 commenti meno recentiNascondi -2 commenti meno recenti

Accedi per commentare.

### Risposte (1)

Hugo il 2 Lug 2013
You can use surf as you did with the cylinder. You then might need to define the grid small enough and set the colours outside the circle as NaN instead of zero.
##### 4 CommentiMostra 2 commenti meno recentiNascondi 2 commenti meno recenti
Davit Hakobyan il 2 Lug 2013
Can you please provide me some code. I guess for you it will take instant.I am beginner, and I get lost in process with in errors.
Davit Hakobyan il 2 Lug 2013
Thank I have solved the problem

Accedi per commentare.

### Categorie

Scopri di più su Surface and Mesh Plots in Help Center e File Exchange

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by