Mecit,
you should be able to do this by constructing the eq.D expression as a string. For example, your m file will look like this:
.
.
D1=0.01 % numerical value of D1 parameter
B=0.005 % numerical value of B parameter
.
.
equ.D = [num2str(D1) '*exp(-' num2str(B) '*(1-c/10))'];
.
.
As you see all the string "pieces" in "[ ]" are concatenated together. you convert numbers to strings using num2str function, and leave the remainder of the expressions as string pieces enclosed between ' ' marks.
Hope this helps,
Ozgur
I have a Comsol model m file and I want to convert it to a function m file. I am using diffusion application mode and my diffusion coefficient is a function of concentration.
D=D1*exp(-B*(1-c/10))
In my model m file ;
eq.D='D1*exp(-B*(1-c/10))'
In the function m file I would like to input 'D1 and B1' as inputs. However since it is a string defined in eq.D the function input parameters are not recognised.
My question is that :
How can I convert the model m file to a function m file such that my parameters in the diffusion coefficient will be recognised as inputs in the function?
Thanks a lot
Mecit
you should be able to do this by constructing the eq.D expression as a string. For example, your m file will look like this:
.
.
D1=0.01 % numerical value of D1 parameter
B=0.005 % numerical value of B parameter
.
.
equ.D = [num2str(D1) '*exp(-' num2str(B) '*(1-c/10))'];
.
.
As you see all the string "pieces" in "[ ]" are concatenated together. you convert numbers to strings using num2str function, and leave the remainder of the expressions as string pieces enclosed between ' ' marks.
Hope this helps,
Ozgur
I have a Comsol model m file and I want to convert it to a function m file. I am using diffusion application mode and my diffusion coefficient is a function of concentration.
D=D1*exp(-B*(1-c/10))
In my model m file ;
eq.D='D1*exp(-B*(1-c/10))'
In the function m file I would like to input 'D1 and B1' as inputs. However since it is a string defined in eq.D the function input parameters are not recognised.
My question is that :
How can I convert the model m file to a function m file such that my parameters in the diffusion coefficient will be recognised as inputs in the function?
Thanks a lot
Mecit