lsqnonlin question curve fitting
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hello. I am trying to use lsqcurve fit and lsqnonlin commands in order to approximate a curve that derives from the set (Vi,Pi) of data, which represent the Voltage and Power measured from a photovoltaic panel
The equation that i need to use is :
P = Vi*Iph - Vi*Is * e^((Vi+Ii*Rs)/17.796) - (Vi+Ii*Rs)/Rsh.
The parameters that i need to calculate are : Iph, Is, Rsh . Rs is a known number. My problem is that i need to do it in the following way. I have a matrix V = Vi that contains all measured voltage values and P that contains all the measured power values . I also have all measured current values , which means i know all pairs of (Vi,Ii). I want to create a function that takes as inputs some elements of the V matrix ( a number of voltage measurements) but i want Ii to change every time, that means that for every given Vi i use i want to enter the Ii that makes up the pair (Vi,Ii). What i mean is that i do not want to use the Ii as measurements to help me approximate the actual curve, but i want to use them as parameters that change each time i call the function. I have searched on the net for possible solutions, but since i am new to Matlab i have had a hard time implementing it. Any help appreciated :)
0 commentaires
Réponses (2)
Torsten
le 23 Jan 2015
Although I read your question several times, I still don't understand what you are asking for.
Could you provide a small example for explanation ?
Best wishes
Torsten.
0 commentaires
Star Strider
le 23 Jan 2015
I would use lsqcurvefit and then loop through the corresponding ‘Vi’, ‘Ii’ and ‘P’ values. You will get different parameter estimates with each iteration.
The function to fit:
% Original Equation: P = Vi*Iph - Vi*Is * e^((Vi+Ii*Rs)/17.796) - (Vi+Ii*Rs)/Rsh.
% Parameters: Iph = b(1), Is = b(2), Rsh = b(3)
% Independent Variables: IV = [Ii Vi]; Both Column Vectors
Pfit = @(b,IV) IV(:,2).*b(1) - IV(:,2).*b(2) .* exp((IV(:,2)+IV(:,1)*Rs)/17.796) - (IV(:,2)+IV(:,1)*Rs)./b(3);
3 commentaires
Star Strider
le 25 Jan 2015
Modifié(e) : Star Strider
le 25 Jan 2015
My pleasure.
Your ‘myfun’ function ‘F’ assignment needs to be fully vectorised:
F = b(1)-b(2).*exp((IV(:,2)+IV(:,1).*Rs0)./a0)+(IV(:,2)+IV(:,1).*Rs0)./b(3);
since that could be the problem.
Guessing here, but also be certain that ‘Vpv’ is composed of two column vectors (that is, it is an (Nx2) matrix) and that ‘Ipv’ is an (Nx1) column vector, and that ‘myfun’ returns a (Nx1) column vector as well. That should eliminate that error. (To be certain ‘myfun’ is working correctly so it will work with lsqcurvefit, you might want to run ‘myfun’ with your initial parameter estimates and your ‘IV’ matrix once to be certain it does, before you use it in lsqcurvefit.)
Voir également
Catégories
En savoir plus sur Linear Programming and Mixed-Integer Linear Programming dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!