Note: This discussion is about an older version of the COMSOL Multiphysics® software. The information provided may be out of date.

Discussion Closed This discussion was created more than 6 months ago and has been closed. To start a new discussion with a link back to this one, click here.

Error when call a Matlab function

Please login with a confirmed email address before reporting spam

Hi,

I have created a matlab function, function[r]= vel(w1,w2), to the velocity of reaction in a reacting flow model. The function has two inputs, w1 and w2, the mass fractions of the reagents, which are dependent variables in the Comsol model. I expect that the function returns a real number, but I get the next error message when I try to run Comsol:

Error using ==> mtimes
Inner matrix dimensions must agree.
- Function: vel

Must the function return be a matrix? What is the size of this matrix? because I think that the inputs, w1 and w2, are scalar numbers.

Thanks for any help.

2 Replies Last Post 18.06.2014, 09:36 GMT-4
Ivar KJELBERG COMSOL Multiphysics(r) fan, retired, former "Senior Expert" at CSEM SA (CH)

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 18.06.2014, 02:28 GMT-4
Hi

check the doc, COMSOL expects only arrays back, even single item arrays from matlab

--
Good luck
Ivar
Hi check the doc, COMSOL expects only arrays back, even single item arrays from matlab -- Good luck Ivar

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 18.06.2014, 09:36 GMT-4
Hi

But what is the size of the array? I ask this because I think that the inputs, w1 and w2, are scalar numbers. So, I don't know how to build the array. I am trying a simple function just for testing:

r=1000*w1*w2

Thanks for your help.
Hi But what is the size of the array? I ask this because I think that the inputs, w1 and w2, are scalar numbers. So, I don't know how to build the array. I am trying a simple function just for testing: r=1000*w1*w2 Thanks for your help.

Note that while COMSOL employees may participate in the discussion forum, COMSOL® software users who are on-subscription should submit their questions via the Support Center for a more comprehensive response from the Technical Support team.