Best-Fit line only extends in the positive x-axis direction
Afficher commentaires plus anciens
Alright so I've written this piece of code in Matlab with the goal of having a line of best fit plotted in place of my two data arrays so that I can see where the line crosses the x&y axes visually. The only problem is, the line of best fit only extends in the positive x-axis direction, so it never actually crosses the x and y axes. What am I missing?
y = [200 300 400 500]; % Lambda
invy = 1./y; %1/Lambda
V = [4.00 1.86 0.85 0.21]; % Vo
q = 1.6e-19; % Charge of Electron
p = polyfit(invy,V,1);
f = polyval(p,invy);
figure(1)
plot(invy,f)
xlim([-5e-3 5e-3])
ylim([-2 2])
grid on
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Creating, Deleting, and Querying Graphics Objects 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!
