Is there a way to plot everything together using the surf command in matlab?

2 vues (au cours des 30 derniers jours)
Is there a way to plot everything together using the surf command in matlab? right now I can only one z value at a time (i.e.
surf(R,Rc,N_diesel(:,:,1)); , surf(R,Rc,N_diesel(:,:,2));, surf(R,Rc,N_diesel(:,:,3)); ... and so forth)
Can someone point me in the right direction?
My Current Code:
--------------------------------------------------------------------------------------------
T = linspace(250,1000,16);
T_size = length(T);
Rc = linspace(1.001,4.001,7);
rc_size = length(Rc);
R = linspace(12,24,25);
r_size = length(R);
N_diesel = zeros(r_size,rc_size,T_size);
for ki=1:1:T_size
for j=1:1:rc_size
for i=1:1:r_size
k = get_k_air(T(ki));
Calc_Diesel = efficiency(R(i),Rc(j),k);
N_diesel(i,j,ki) = Calc_Diesel;
end
end
end
[Rc,R] = meshgrid(Rc,R);
surf(R,Rc,N_diesel(:,:,1));
x = array2table(round(N_diesel(:,:,1),3,'significant'));
function k = get_k_air(T1)
keys = linspace(250,1000,16);
values = [1.401,1.4,1.398,1.395,1.391,1.387,1.381,1.376,1.37,1.364,1.359,1.354,1.349,1.344,1.34,1.336];
lookup_table = containers.Map(keys,values);
k = lookup_table(T1);
end
function Calc_Diesel = efficiency(R,Rc,k)
N1 = 1/(R.^(k - 1));
N2 = (Rc.^k - 1)/(k.*(Rc - 1));
Calc_Diesel = 1 - (N1*N2);
end

Réponse acceptée

Star Strider
Star Strider le 14 Avr 2019
Use the hold function, and plot the surfaces in a loop.
Try this:
figure
hold all
for k1 = 1:size(N_diesel,3)
surf(R,Rc,N_diesel(:,:,k1));
x{k1} = array2table(round(N_diesel(:,:,k1),3,'significant'));
end
hold off
view(30,30)
grid on
Full context:
T = linspace(250,1000,16);
T_size = length(T);
Rc = linspace(1.001,4.001,7);
rc_size = length(Rc);
R = linspace(12,24,25);
r_size = length(R);
N_diesel = zeros(r_size,rc_size,T_size);
for ki=1:1:T_size
for j=1:1:rc_size
for i=1:1:r_size
k = get_k_air(T(ki));
Calc_Diesel = efficiency(R(i),Rc(j),k);
N_diesel(i,j,ki) = Calc_Diesel;
end
end
end
[Rc,R] = meshgrid(Rc,R);
figure
hold all
for k1 = 1:size(N_diesel,3)
surf(R,Rc,N_diesel(:,:,k1));
x{k1} = array2table(round(N_diesel(:,:,k1),3,'significant'));
end
hold off
view(30,30)
grid on
function k = get_k_air(T1)
keys = linspace(250,1000,16);
values = [1.401,1.4,1.398,1.395,1.391,1.387,1.381,1.376,1.37,1.364,1.359,1.354,1.349,1.344,1.34,1.336];
lookup_table = containers.Map(keys,values);
k = lookup_table(T1);
end
function Calc_Diesel = efficiency(R,Rc,k)
N1 = 1/(R.^(k - 1));
N2 = (Rc.^k - 1)/(k.*(Rc - 1));
Calc_Diesel = 1 - (N1*N2);
end

Plus de réponses (0)

Catégories

En savoir plus sur Timing and presenting 2D and 3D stimuli dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by