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.

errors using matlab script that don't occur when running in gui

Please login with a confirmed email address before reporting spam

Hi,

I am running a simulation which couples 2 odes and 2 pdes together in a simple 1 dimensional mode. The simulation requires the two stages are simulated sequentially. In the first stage the temperature is a constant variable. The second stage then uses the final conditions from the initial stage as the ICs and has the temperature T activated as an application mode where I specify the dT/dt=constant and elimate the constant value T.

The simulation ran fine until I began implementing my own matlab functions as scalar expressions. When I add them and run the simulation in the gui, there are no problems. When I save the simulation as a mfile script and try running it in the matlab workspace i get errors in between the saving the conditions of the first stage and running the second stage. The error is as follows:

-------------------------------------------------------------
??? Java exception occurred:
Exception:
com.femlab.server.MlError: Error using ==> rdivide
Matrix dimensions must agree.
(rethrown as com.femlab.jni.FlNativeException)
Messages:
Error using ==> rdivide
Matrix dimensions must agree.

Error in callback


Stack trace:

at callback.cpp, row 113, ()

at com.femlab.solver.FlSolver.femTime(Native Method)

at com.femlab.solver.FemTime.run(SourceFile:69)

at com.femlab.server.FlRunner.run(SourceFile:120)

at com.femlab.server.MlProgressDlg.runAndWait(SourceFile:142)

at com.femlab.server.FlRunnable.runAndWait(SourceFile:69)


Error in ==> femsolver at 225
solobj.runAndWait(report, 'Solution Progress', loopTime);

Error in ==> femtime at 61
varargout = femsolver(mfilename,'FemTime',varargin{:});

Error in ==> testfunctioninput2 at 389
fem.sol=femtime(fem, ...
----------------------------------------------------------------


Any ideas what might be occuring? After trying the failing script in matlab, i reopen it in the gui and it again works fine.

Please Help!

William M.

1 Reply Last Post 24.10.2009, 13:04 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: 2 decades ago 24.10.2009, 13:04 GMT-4
Hi

I'm far from my book just now, but there is an issue one can easily get wrong with the matlab functions in COMSOL, it has to do with accepting vectors as inputs. There is a few places in the matlab interface doc were this is mentionned.

I always check that my functions are compatible with array data entries (using .* and ./ in matlab) perhaps it is related with your issue, but I'm not sure, these error messages are rather cryptic, I agree.

Good luck
Ivar
Hi I'm far from my book just now, but there is an issue one can easily get wrong with the matlab functions in COMSOL, it has to do with accepting vectors as inputs. There is a few places in the matlab interface doc were this is mentionned. I always check that my functions are compatible with array data entries (using .* and ./ in matlab) perhaps it is related with your issue, but I'm not sure, these error messages are rather cryptic, I agree. Good luck Ivar

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.