Im trying to find the zeroes of the two lines on the graphs I've made
Afficher commentaires plus anciens
I've looked around a bit and either I haven't been putting in stuff the right way or I haven't found the help I'm looking for. I am making plots for the power a solar collector collects through out a day. I need to find where the lines hit 0 on the x axis so I can determine sunrise and sunset of each line so I can intergrate for the day. The last few lines are a piece I couldn't get to work properly. This is what I have so far:
n = 32;
S = 23.45*sind(360*(284 + n)/365);
phi = 38.9072;
tsol = 0:1/60:24;
w = 15*(tsol-12);
Gsc = 1353;
Go = Gsc*(1 + 0.033*cosd((360*n)/365))*(cosd(phi)*cosd(S)*cosd(w) + sind(phi)*sind(S));
plot(tsol,Go)
hold on
Y = 30;
B = 50;
theta1 = sind(S)*sind(phi)*cosd(B) - sind(S)*cosd(phi)*sind(B)*cosd(Y) + cosd(S)*cosd(phi)*cosd(B)*cosd(w)+ cosd(S)*sind(phi)*sind(B)*cosd(Y)*cosd(w) + cosd(S)*sind(B)*sind(Y)*sind(w);
Got = Gsc*(1 + 0.033*cosd((360*n)/365))*theta1;
plot(tsol,Got)
hold off
grid on
title('Homework #3, Question 1b')
xlabel('Time of day (Hours)')
ylabel('Solar Radiation on horizontal plane')
xlim([0 24])
legend('Horrizontal','Angled')
syms tsol Go
tsol = solve([0 == Gsc*(1 + 0.033*cosd((360*n)/365))*(cosd(phi)*cosd(S)*cosd(w) + sind(phi)*sind(S))-Go], tsol)
Réponse acceptée
Plus de réponses (2)
x = linspace(-1.5*pi,1.5*pi,1000);
y = sin(x);
figure(), plot(x,y);
[xi, yi] = polyxpoly(x,y,x,zeros(size(x)));
hold on, plot(xi,yi,'ok','MarkerFaceColor','k')
dpb
le 8 Fév 2022
I lack symbolic TB, but it's easy enough to just find the crossing point from linear interpolation. MATLAB interp1 requires a unique sorted variable as its independent, so to do the backwards interpolation to find x given y with a double-valued function, have to segregate the regions -- again, this is easy enough.
Since is HM, I'll only show the result; you're honor-bound to determine how it works and submit your own version... :)
iz1=find(Got>0,1);
iz2=find(Got>0,1,'last');
tZ1=interp1(Got(iz1-1:iz1),tsol(iz1-1:iz1),0);
tZ2=interp1(Got(iz2:iz2+1),tsol(iz2:iz2+1),0)
xline(tZ1,'r:')
xline(tZ2,'r:')
Catégories
En savoir plus sur Mathematics dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

