How to plot 3d mesh surface?
11 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
prem kumar
el 29 de En. de 2022
Comentada: prem kumar
el 30 de En. de 2022
I wanted to know how to obtain a 3D mesh surface plot of Beta1,Beta2,Beta3,Beta4,Beta5 for the following code with k=1:24,L=0:80 degree for dn=100.initially it was only one Beta,k and L but it was hard for me to code as iam a beginner so i separated for each L=0:20:80 i made it like Beta1,Beta2,Beta3,Beta4,Beta5,now i am current stuck with how to plot all this Betas as Beta,k and L variable into a 3d mesh surface plot.Can anyone give a hint on how to resolve this ?
%Part A
% a)plot graph solar declination versus the day number
dn=1:1:365;
x=(360/365*(dn+284));
sdelta=23.45*(sind(x));
figure(1)
plot(dn,sdelta)
grid on
title('solar declination vs number of days')
xlabel('number of days')
ylabel('solar declination')
% b)i)
[a,b]=max(sdelta);
[c,d]=max(a);
disp('max value and number of days')
disp([c,d]);
%b)ii)
[e,f]=min(sdelta);
[g,h]=min(e);
disp('min value and number of days')
disp([g,h]);
%b)iii)
sdelta = rand(1,365);
targetangle = [-0.3 0.3];
Numberdays = sdelta >= targetangle(1) ...
& sdelta <= targetangle(2);
numberofdays = nnz(Numberdays);
disp('the number days for equinox ')
disp(numberofdays);
%c)
dn=1:1:365;
x=(360/365*(dn+284));
sdelta=23.45*(sind(x));
dni = [15, 45, 75, 105, 135, 165, 195, 225, 255, 285, 315, 345] ;
sdeltai = interp1(dn,sdelta,dni);
disp(' dni sdeltai');
disp([dni',sdeltai'])
%PartB a)
for dn=100
for L=0
sdelta=7.53377356668594;
k=0.5:0.5:24;
lamda=15*(12-k);
PP=sind(sdelta).*sind(L)+cosd(sdelta).*cosd(L).*cosd(lamda);
Beta1=asind(PP);
end
for L=20
sdelta=7.53377356668594;
k=0.5:0.5:24;
lamda=15*(12-k);
PP=sind(sdelta).*sind(L)+cosd(sdelta).*cosd(L).*cosd(lamda);
Beta2=asind(PP);
end
for L=40
sdelta=7.53377356668594;
k=0.5:0.5:24;
lamda=15*(12-k);
PP1=sind(sdelta).*sind(L)+cosd(sdelta).*cosd(L).*cosd(lamda);
Beta3=asind(PP1);
end
for L=60
sdelta=7.53377356668594;
k=0.5:0.5:24;
lamda=15*(12-k);
PP2=sind(sdelta).*sind(L)+cosd(sdelta).*cosd(L).*cosd(lamda);
Beta4=asind(PP2);
end
for L=80
sdelta=7.53377356668594;
k=0.5:0.5:24;
lamda=15*(12-k);
PP3=sind(sdelta).*sind(L)+cosd(sdelta).*cosd(L).*cosd(lamda);
Beta5=asind(PP3);
end
figure(2)
grid on
plot(k,Beta1)
hold on;
plot(k,Beta2)
plot(k,Beta3)
plot(k,Beta4)
plot(k,Beta5)
hold off;
end
%b)
disp('dn=100')
disp(' Latitude degree,L' )
disp('============================================================')
disp('Solar time,k 0 20 40 60 80 ')
disp('============================================================')
disp([k',Beta1',Beta2',Beta3',Beta4',Beta5'])
%c)
for L=0
max(Beta1);
disp('max value at L=80')
disp(max(Beta1));
end
for L=20
max(Beta2);
disp('max value at L=20')
disp(max(Beta2));
end
for L=40
max(Beta3);
disp('max value at L=40')
disp(max(Beta3));
end
for L=60
max(Beta4);
disp('max value at L=60')
disp(max(Beta4));
end
for L=80
max(Beta5);
disp('max value at L=80')
disp(max(Beta5));
end
0 comentarios
Respuesta aceptada
Voss
el 29 de En. de 2022
See below for various changes, including the one you asked about.
%Part A
% a)plot graph solar declination versus the day number
dn=1:1:365;
x=(360/365*(dn+284));
sdelta=23.45*(sind(x));
figure(1)
plot(dn,sdelta)
grid on
title('solar declination vs number of days')
xlabel('number of days')
ylabel('solar declination')
% b)i)
[a,b]=max(sdelta);
[c,d]=max(a);
disp('max value and number of days')
disp([c,b(d)]);
%b)ii)
[e,f]=min(sdelta);
[g,h]=min(e);
disp('min value and number of days')
disp([g,f(h)]);
%b)iii)
sdelta = rand(1,365);
targetangle = [-0.3 0.3];
Numberdays = sdelta >= targetangle(1) ...
& sdelta <= targetangle(2);
numberofdays = nnz(Numberdays);
disp('the number days for equinox ')
disp(numberofdays);
%c)
dn=1:1:365;
x=(360/365*(dn+284));
sdelta=23.45*(sind(x));
dni = [15, 45, 75, 105, 135, 165, 195, 225, 255, 285, 315, 345] ;
% sdeltai = interp1(dn,sdelta,dni);
sdeltai = sdelta(dni);
disp(' dni sdeltai');
disp([dni',sdeltai'])
%PartB a)
k=0.5:0.5:24;
lamda=15*(12-k);
L = 0:20:80;
for dn=100
Beta = NaN(numel(k),numel(L));
for i = 1:numel(L)
Beta(:,i) = asind(sind(sdelta(dn)).*sind(L(i))+cosd(sdelta(dn)).*cosd(L(i)).*cosd(lamda)).';
end
figure(2)
plot(k,Beta)
grid on
end
%b)
disp('dn=100')
disp(' Latitude degree,L' )
disp('============================================================')
disp('Solar time,k 0 20 40 60 80 ')
disp('============================================================')
% disp([k',Beta1',Beta2',Beta3',Beta4',Beta5'])
disp([k', Beta]);
% Beta = [Beta1',Beta2',Beta3',Beta4',Beta5'];
figure
surf(0:20:80,k,Beta);
colorbar();
%c)
max_Beta = max(Beta,[],1);
L = 0:20:80;
for i = 1:numel(L)
disp(sprintf('max value at L=%d',L(i)));
disp(max_Beta(i));
end
Más respuestas (0)
Ver también
Categorías
Más información sobre 2-D and 3-D Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!




