Asked by Bruno Martins
on 12 Jan 2019

Hello!

I'm trying to solve non linear equations for 8760 lines, meaning each line has a non-linear equation, all the vectors are of the size (8760,1). The code is below:

% Model start

Vwind_low = data(:,4)*0.51;

T_water = mi + ((alpha-mi)./(1+exp(gamma*(beta-data(:,3)))));

Tcell = 1.8081+0.9282*data(:,3)+0.021*data(:,2)-1.221*Vwind_low+0.0246*T_water;

TcellK = Tcell+273.15;

Isc = Isc_ref*data(:,2)/G_ref;

A = A_ref*TcellK/T_STC;

Ebg = 1.12*(1-0.0002677*(TcellK-T_STC));

Io = Io_ref*((TcellK/298.15).^3).*exp((1/k)*((1.12/T_STC)-(Ebg./TcellK)));

% Objective function

fun = @myfun

x0 = ones(8760,1)*39; % Initial guess is 39

for i=1:8760

x(i) = fsolve(fun,x0);

end

My myfun file is below:

function F = myfun (x)

for j=1:8760

F = exp(x(i)./A(j)) - ((Isc(j)./Io(j) + 1)./(1 + x(i)./A(j)));

end

My question is: the non-linear equation depends on the parameters A, Isc and Io that I calculated in the main code. How do I call these calculated parameters to the function?

Also, is this the way you guys would solve this problem? Is there another way?

Thank you!

Opportunities for recent engineering grads.

Apply Today
## 8 Comments

## Walter Roberson (view profile)

Direct link to this comment:https://kr.mathworks.com/matlabcentral/answers/439450-solving-a-non-linear-problem-for-several-lines#comment_659649

## Bruno Martins (view profile)

Direct link to this comment:https://kr.mathworks.com/matlabcentral/answers/439450-solving-a-non-linear-problem-for-several-lines#comment_659747

## Walter Roberson (view profile)

Direct link to this comment:https://kr.mathworks.com/matlabcentral/answers/439450-solving-a-non-linear-problem-for-several-lines#comment_659756

## Bruno Martins (view profile)

Direct link to this comment:https://kr.mathworks.com/matlabcentral/answers/439450-solving-a-non-linear-problem-for-several-lines#comment_659761

## Walter Roberson (view profile)

Direct link to this comment:https://kr.mathworks.com/matlabcentral/answers/439450-solving-a-non-linear-problem-for-several-lines#comment_659764

## Bruno Martins (view profile)

Direct link to this comment:https://kr.mathworks.com/matlabcentral/answers/439450-solving-a-non-linear-problem-for-several-lines#comment_660296

## Walter Roberson (view profile)

Direct link to this comment:https://kr.mathworks.com/matlabcentral/answers/439450-solving-a-non-linear-problem-for-several-lines#comment_660342

## Bruno Martins (view profile)

Direct link to this comment:https://kr.mathworks.com/matlabcentral/answers/439450-solving-a-non-linear-problem-for-several-lines#comment_660352

Sign in to comment.