How to write function for two variables
Mostrar comentarios más antiguos
I am trying to write down the function to predict "y" having two independent variables "x1 & x2". Here is my code for the function;
function y=Project_func(beta0,x1,x2)
y=100./(1+exp((-beta0(1).*(-2.4-(39.7*(1+x1).^(-2.8))))+(beta0(2).*(-2.4-(39.7*(1+x1).^(-2.8))).*log10(100.*x2))));
end;
but once I run the code it does not spit the y values as desired because I have predicted values taken from the excel. I want to solve it in the Matlab. Here are the equations. C1 & C2 are parameters having intial guess.

7 comentarios
but once I run the code it does not spit the y values as desired because I have predicted values taken from the excel.
Dyuman Joshi
el 22 de Feb. de 2023
Also, you have rounded out values in your code as compared to the formula, that will give a slightly different result and verify that you are using the right log base.
Faizan Lali
el 22 de Feb. de 2023
Dyuman Joshi
el 22 de Feb. de 2023
What are you trying to plot? Please attach/provide relevant code and data.
"I am trying to use handle command ..."
What do you mean by handle command?
Faizan Lali
el 22 de Feb. de 2023
%figure;
%hold on
%set(gca, 'fontsize',14,'fontweight','bold');
for i=1:p
h2(i) = mesh(X,Y,Xp(:,:,i));
end
%plot C vs t to know the total span
ypred=fnameFOR(beta0,X,Y);
h2(i+1)=mesh(X,Y,ypred);
You've not provided any data nor even described the variables; so nobody can see your workspace from here to know...but the above code tries to put p mesh plots on the same axis which will look very messy. Probably about all it will leave visible will be the result for whichever plane of the array is the largest in amplitude, it occluding the others.
Then, you add one more yet on top of those; one presumes fnameFOR is the name for the preceding function m-file; that's a very non-informative name, but MATLAB doesn't really care.
Now, the h array will contain the handles to the various mesh plot objects created; what, specifically you had in mind to do to them after plotting is unclear as to why you did save the handles; they're only of use to be able to make changes to the properties of the plot afterwards if desired. Or, you could hide all of them except one by setting 'Visible','off' so could see what each plane did look like.
It's certainly unclear what you think isn't working...
Faizan Lali
el 23 de Feb. de 2023
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Logical en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
