# MATLAB: Lsqcurvefit for two different equations and variables

curve fittinglsqcurvefitMATLABnonlinear curve fittingtwo variables

Hello,
i have a data which consists of one input value (i) and two output values (Y) values, say Y1 and Y2. I want to fit my experimental data to a model using lsqcurvefit. what i know is that i can fit my data using only one X variable and one Y variable. is there a way that i can optimize my functions to fit both variables at the same time?
``i = [1.17451E+001.87115E+002.98100E+004.74915E+007.56606E+001.20538E+011.92034E+013.05936E+014.87399E+017.76494E+011.23706E+021.97081E+023.13978E+025.00210E+027.96904E+021.26958E+032.02262E+033.22231E+035.13358E+03];y1 = [242.5088007444.8689004802.83359791425.3055682489.3122394277.0045987229.17952712405.9964820430.9926533235.4626253403.3419187814.94488138006.2801213871.8819326838.3103492534.4889731921.93241072549.391549866.402];y2 = [3377.0170695268.9329218164.85358512566.3875919209.1796529163.7591843975.8767364027.872195789.07289142240.1411209646.5318298137.6129433807.5582626647.3615898659.29931279418.6771808323.2092537378.0743534598.31];% i have 3 parameters % define the equationsy1_theo = @(x,xdata)x(1).*(1+(x(2)./xdata).^(log10(2)/x(3))).^(-x(3)./log10 (2));% define dy2_theo = @(x,xdata)90./(1+(xdata./x(2)).^(log10(2)./x(3)));% initial valuesx0 = [1E+9 1000 1];% specify the boundslb=[0 0 0];ub = [inf inf inf];% optimize[x,resnorm,~,exitflag,output] = lsqcurvefit([y1_theo y2_theo],x0,i,[y1 y2],lb,ub)``
I have tried to write the code as above, but it is not working, can someone please help me with this?

``y_theo = @(x,xdata) [x(1).*(1+(x(2)./xdata).^(log10(2)/x(3))).^(-x(3)./log10 (2)),  90./(1+(xdata./x(2)).^(log10(2)./x(3)))];x0 = [1E+9 1000 1];% specify the boundslb=[0 0 0];ub = [inf inf inf];% optimize[x,resnorm,~,exitflag,output] = lsqcurvefit(y_theo,x0,i,[y1 y2],lb,ub)figureplot(i, [y1 y2], 'p')hold onplot(i, y_theo(x,i), '-r')hold offgrid``