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

2 ビュー (過去 30 日間)
Gregory Drake
Gregory Drake 2019 年 4 月 14 日
コメント済み: Star Strider 2019 年 4 月 14 日
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

採用された回答

Star Strider
Star Strider 2019 年 4 月 14 日
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
  2 件のコメント
Gregory Drake
Gregory Drake 2019 年 4 月 14 日
Thanks.
Star Strider
Star Strider 2019 年 4 月 14 日
As always, my pleasure.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeTiming and presenting 2D and 3D stimuli についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by