# how can I plot a matrix against two other ones? (need to a matrix 3d plotting )

2 views (last 30 days)
Mahsa Babaee on 30 Jul 2021
Answered: darova on 30 Jul 2021
Hello Experted Friends!
I am trying to plot a matrix named T in my code against x and y at some t values. I was wondering if you could guide me what should I include in my code?
%%% Temperature Distribution Induced by Laser in a Singler Layer Tissue: %
% Cleaning:
clc;
clear;
% Parameters:
Lx= 0.040; Ly= 0.040; Lz= 0.00008; tmax= 5;
k= 0.25; rho= 1200; Cp=3600 ; alpha= k/(rho*Cp);
omega_b= 0; rho_b= 1060; C_b= 3770;
omega= sqrt(rho_b*C_b*omega_b/k);
w= omega^2;
T_b=310 ; T_ini=309 ; T_ts=310 ;
nmax=10 ; mmax=10 ; lmax=10 ;
mu= 80e+03;
I0=1 ; q_met= 368.1;
OMEGA= w*(T_b- T_ts)*+q_met/k;
%%%%%%%%%%%%
beta= zeros(1,nmax);
for n=1:nmax
beta(n)= n*pi/Lx;
end
gamma= zeros(1,mmax);
for m=1:mmax
gamma(m)= m*pi/Ly;
end
sigma= zeros(1,lmax);
for l=1:lmax
sigma(l)= (2*l-1)*pi/(2*Lz);
end
landa2= zeros(nmax,mmax,lmax);
for n=1:nmax
for m=1:mmax
for l=1:lmax
landa2(n,m,l)= (beta(n))^2+(gamma(m))^2+(sigma(l))^2;
end
end
end
Zeim= zeros(1,lmax);
for l=1:lmax
Zeim(l)= (mu*sigma(l)*exp(-mu*Lz)*sin(sigma(l)*Lz)-mu^2*exp(-mu*Lz)*cos(sigma(l)*Lz)+mu^2)/(mu^2+sigma(l)^2);
end
XI= zeros(1,nmax);
for n=1:nmax
XI(n)= 1/beta(n)*(1-cos(beta(n)*Lx));
end
YI= zeros(1,mmax);
for m=1:mmax
YI(m)= 1/gamma(m)*(1-cos(gamma(m)*Ly));
end
ZI= zeros(1,lmax);
for l=1:lmax
ZI(l)= 1/sigma(l)*sin(sigma(l)*Lz);
end
ZI2= Lz/2;
ql= zeros(nmax,mmax);
for n=1:nmax
for m=1:mmax
ql(n,m)= 1/(beta(n)*gamma(m))*(cos(beta(n)*Lx)-1)*(cos(gamma(m)*Ly)-1); %ql= int(f(x,y)*X(n,x)*Y(m,y),0,Lx,0,Ly) % Assumption f(x,y)=1
end
end
%syms t s
%m_t= 1;
%M_s= laplace(m_t) ;
a= zeros(nmax,mmax,lmax); d= zeros(nmax,mmax,lmax);
S1= zeros(nmax,mmax,lmax); S2= zeros(nmax,mmax,lmax);
for n=1:nmax
for m=1:mmax
for l=1:lmax
% a(m,n,l)= (4*I0*ql* M_s*Zeim)/(Lx*Ly*k/alpha*ZI2);
% d(m,n,l)= (T_ini-T_ts+(OMEGA*alpha/s))*4*XI*YI*ZI/(Lx*Ly*ZI2);
S1=0; S2=0; T= zeros(nmax,mmax,lmax);
for x=0:Lx/10:Lx
for y= 0:Ly/10:Ly
for t=0:0.01:tmax
S1= S1+(4*I0*ql(n,m)*Zeim(l)*(1-exp(-alpha*landa2(n,m,l)*t)))/(Lx*Ly*k*ZI2*landa2(n,m,l));
S2= S2+(4*XI(n)*YI(m)*ZI(l))*((T_ini-T_ts)*exp(-alpha*landa2(n,m,l)*t)-OMEGA*(exp(-alpha*landa2(n,m,l)*t)-1)/landa2(n,m,l))/(Lx*Ly*ZI2);
T(n,m,l)=T(n,m,l)+(S1+S2)*sin(beta(n)*x)*sin(gamma(m)*y);
end
end
end
% 3D-Plot:
% How should I plot T against x and y at certain t values?
end
end
end

darova on 30 Jul 2021
Use surf
[x,y,z] = peaks(30);
h = surf(x,y,z);
for i = 1:20
z = z + 0.5*rand(30);
set(h,'zdata',z)
pause(0.5)
end

### Categories

Find more on Descriptive Statistics and Visualization 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!