for optimaization one parameter i got,
clear,clc
t=25; %temperature (C)
T=t+273; %temperature (K)
i_ph=3.113; %phase current [A]
e_g=1.12; %band gap [eV]
c_01=170.80; %co-efficient of saturation current [AK^(-3)]
m_1=1.00; %diode factor
e=1.6*10^-(19); %electronvolt [j]
k=1.38*10^-(23); %Boltzmann constant [JK^(-1)]
U=(0:0.001:0.6); %voltage [V]
% Ut=(k*T)/e;
Ut=0.0257
I= i_ph - (c_01 * T^3 * exp(-((e_g*e)/(k*T)))) .* (exp(U./(m_1*Ut))-1);
plot(U,I,'linewidth',2.5,'DisplayName','real curve');
axis([0,0.6,0,3.5]);
xlabel('Spannung U');
ylabel('Strom A');
grid on;
% legend show
hold on
% c_01_guess=870.80; %co-efficient of saturation current [AK^(-3)]
%
% I= i_ph - (c_01_guess * T^3 * exp(-((e_g*e)/(k*T)))) .* (exp(U./(m_1*Ut))-1);
% plot(U,I,'linewidth',2.5,'DisplayName','guessed curve');
%first define optimization variables
c_01=optimvar('c_01');
m_1=optimvar('m_1');
%create expression for the objective function, which is the square to minimize
fun=i_ph - (c_01 * T^3 * exp(-((e_g*e)/(k*T)))) .* (exp(U./(m_1*Ut))-1);
obj=sum((fun - I).^2);
%create an optimized problem with the function obj
lsqproblem = optimproblem("Objective",obj)
%for the problem based appraoch, specify the initial point as a structure,with the variable names and fields of the structure
x0.c_01 = [870.8]
x0.m_1 = [1.2]
%Review the problem formulation
show(lsqproblem)
%solving problem using Isqnonlin
[sol,fval] = solve(lsqproblem,x0)
%Plot the resulting solution and original data
% figure
responsedata = evaluate(fun,sol);
plot(U,I,'r*',U,responsedata,'b-');
% plot(U,responsedata,'black--','DisplayName','responsedata')
legend('Original Data','Fitted Curve')
legend show
axis([0,0.6,0,3.5]);
xlabel('Spannung U');
ylabel('Strom A');
grid on;
% display solved c_01 value
disp(sol.c_01)
disp(sol.m_1)