Surf plot is black
35 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Athanasios Triantafyllou
am 20 Apr. 2022
Beantwortet: Voss
am 21 Apr. 2022
Hello everyone,
I am trying to make a 3D graph using the surf command, but all I get is a black surface. Does anyone know how to fix this? I have uploaded two excel files with the data for y (time) and z (concentration).
d_aem = 0.562*10^(-3);
K_m = 25;
hours = 2.2;
x = linspace(0,d_aem,K_m)';
y = t;
z = c_so4_aem;
figure(9)
surf(x,y,z);
ylabel('Time (s)')
zlabel('Concentration (mol m^-^3)')
title('Concentration of SO_4 in AEM (mol m^-^3)')
[Xq,Yq] = meshgrid((0:d_aem/K_m:d_aem),0:10:3600*hours);
Zq = interp2(x,y,z,Xq,Yq,'linear');
surf(Xq,Yq,Zq);
colorbar
xlabel('Membrane layer (m)')
ylabel('Time (s)')
zlabel('Concentration (mol m^-^3)')
figure(10)
[C,h] = contourf(Xq,Yq,Zq,15);
h.LevelList=round(h.LevelList,0);
clabel(C,h);
colorbar
colormap('Jet')
xlabel('Membrane layer (m)')
ylabel('Time (s)')
title('Concentration of SO_4 in AEM (mol m^-^3)')
0 Kommentare
Akzeptierte Antwort
Voss
am 21 Apr. 2022
The reason you get a surface that's all black is that the grid is too fine, so all you see are the black lines between grid cells. To fix it you can use a coarser grid, if that's an option, or you can turn the grid lines off by specifying 'EdgeColor','none' when the surface is created (or after it's created).
Here's your code but with 'EdgeColor','none' in second call to surf. (The first surface looks ok, but you could turn the grid lines off for that one as well, of course.)
t = readmatrix('time.xlsx');
c_so4_aem = readmatrix('concentration.xlsx');
d_aem = 0.562*10^(-3);
K_m = 25;
hours = 2.2;
x = linspace(0,d_aem,K_m)';
y = t;
z = c_so4_aem;
figure(9)
surf(x,y,z);
ylabel('Time (s)')
zlabel('Concentration (mol m^-^3)')
title('Concentration of SO_4 in AEM (mol m^-^3)')
[Xq,Yq] = meshgrid((0:d_aem/K_m:d_aem),0:10:3600*hours);
Zq = interp2(x,y,z,Xq,Yq,'linear');
surf(Xq,Yq,Zq,'EdgeColor','none');
colorbar
xlabel('Membrane layer (m)')
ylabel('Time (s)')
zlabel('Concentration (mol m^-^3)')
figure(10)
[C,h] = contourf(Xq,Yq,Zq,15);
h.LevelList=round(h.LevelList,0);
clabel(C,h);
colorbar
colormap('Jet')
xlabel('Membrane layer (m)')
ylabel('Time (s)')
title('Concentration of SO_4 in AEM (mol m^-^3)')
0 Kommentare
Weitere Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


