Comsol multiphysics; fzero and inline function with many parameters

  • #1
hadoque
43
1
Hi
I'm trying to get comsol multiphysics to first define an inline
function with 1 variable and 4 parameters, and then run fzero on that
same function. I can do it with two parameters, but no moore.

This works:

Code:
clear
myfun=inline('exp(y).*cos(x)+z', 'x', 'y', 'z');
x1 = fzero(myfun,-5,2,1)

This does not work:

Code:
clear
myfun=inline('exp(y).*cos(x)+z+u', 'x', 'y', 'z', 'u');
x1 = fzero(myfun,-5,2,1,0.3)

C» test
Error: Too few arguments to inline function.


Would be thankful for any hints about this.


/Johan
 
Physics news on Phys.org
  • #2
Hi Johan,
I had a similar issue when trying to use the fzero function in COMSOL Multiphysics. It seems that you need to pass the additional parameter as an anonymous function. Try this:

clear
myfun=inline('exp(y).*cos(x)+z+u', 'x', 'y', 'z', 'u');
x1 = fzero(@(x) myfun(x,-5,2,1,0.3),-5)

Hope this helps!
 

Similar threads

Replies
4
Views
297
Replies
13
Views
2K
Replies
4
Views
2K
Replies
1
Views
2K
Replies
0
Views
1K
Replies
1
Views
1K
Replies
2
Views
5K
Replies
0
Views
2K
Replies
12
Views
2K
Back
Top