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.

COMSOL with MatLab

Please login with a confirmed email address before reporting spam

Hello, Iam using Comsol 4.3b software and Comsol with Matlab 4.3 b software

how to set the path file in matlab with comsol to export the data?

data1 = model.result.export.create('data1', 'Data'); data1.setIndex('expr', 'T', 0); data1.set('filename','filepath\Temperature.txt'); data1.run;

mphsave(model,'<path>/busbar');

how to set the filename and file path in the coding to export the data and how to set the path in the coding??

if i set any file name and file path I couldn't view the file in the comsol software. It is showing me,

"COMSOL MULTIPHYSICS MODEL FILE IS DAMAGED OR INVALID"

whenever i run the matlab program, it is showing me the error as;

Error using busb (line 168) Java exception occurred: Exception: com.comsol.util.exceptions.UnknownEntityException: Unknown property Messages: Unknown property - Property: busb

Stack trace:

at com.comsol.model.internal.impl.PropFeatureImpl.getPropValue(Unknown Source)

at com.comsol.model.internal.impl.PropFeatureImpl.c(Unknown Source)

at com.comsol.model.internal.impl.PropFeatureImpl$22.a(Unknown Source)

at com.comsol.model.internal.impl.PropFeatureImpl$22.execute(Unknown Source)

at com.comsol.model.clientserver.ClientManagerImpl$1.call(Unknown Source)

at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)

at java.util.concurrent.FutureTask.run(Unknown Source)

at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)

at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)

at java.lang.Thread.run(Unknown Source)

how to solve it?..


2 Replies Last Post Oct 30, 2017, 1:41 a.m. EDT
Lars Gregersen COMSOL Employee

Please login with a confirmed email address before reporting spam

Posted: 7 years ago Oct 27, 2017, 5:00 a.m. EDT

Hi Mangai

There are some important things to notice.

When using mphsave you execute a command in the Matlab environment and we use Matlab's current directory when saving if you don't specify a path. You can get the current path that Maltab uses by using the command "pwd". If you wish to save a model in a certain locacation then specify the path and filesname. E.g. mphave(model, 'c:\models\busbar')

Exporting from Comsol using the Comsol API behaves differently. This code data1 = model.result.export.create('data1', 'Data'); data1.setIndex('expr', 'T', 0); data1.set('filename','filepath\Temperature.txt'); data1.run; is executed by Comsol Multiphysics Server and doesn't know anything about Matlab when it runs. Hence the safest way to use this is to specify valid absolute paths to be sure that it is saved in the correct location.

The Programming Reference Manual contains a reference on the command model.modelPath that determines what Comsol Multiphysics Server does when you specify a relative (or no) path.

-------------------
Lars Gregersen
Comsol Denmark
Hi Mangai There are some important things to notice. When using mphsave you execute a command in the Matlab environment and we use Matlab's current directory when saving if you don't specify a path. You can get the current path that Maltab uses by using the command "pwd". If you wish to save a model in a certain locacation then specify the path and filesname. E.g. mphave(model, 'c:\models\busbar') Exporting from Comsol using the Comsol API behaves differently. This code data1 = model.result.export.create('data1', 'Data'); data1.setIndex('expr', 'T', 0); data1.set('filename','filepath\Temperature.txt'); data1.run; is executed by Comsol Multiphysics Server and doesn't know anything about Matlab when it runs. Hence the safest way to use this is to specify valid absolute paths to be sure that it is saved in the correct location. The Programming Reference Manual contains a reference on the command model.modelPath that determines what Comsol Multiphysics Server does when you specify a relative (or no) path.

Please login with a confirmed email address before reporting spam

Posted: 7 years ago Oct 30, 2017, 1:41 a.m. EDT

thank you sir :)

thank you sir :)

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.