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,
I saved my comsol model as a matlab file, to run it in matlab using liveLink but then I have this error.

Java exception occurred:
Exception:
com.comsol.util.exceptions.FlException: Invalid property value
(rethrown as com.comsol.util.exceptions.FlException)
(rethrown as com.comsol.util.exceptions.FlException)
Messages:
Invalid property value

Invalid property value

Invalid property value.
- Property: p

'Control points' is a matrix of real numbers.
- : Expected size is 2 × (0 – 2147483647).
- : Expected unit is: m.
- Property: p (Control points)


Stack trace:

at com.comsol.clientapi.engine.c.handleException(SourceFile:27)

at com.comsol.client.interfaces.g$d.e(SourceFile:536)

at com.comsol.client.interfaces.g.a(SourceFile:238)

at com.comsol.client.interfaces.ClientWebSocketCommandManager.a(SourceFile:464)

at com.comsol.client.interfaces.g.runAndWait(SourceFile:217)

at com.comsol.clientapi.engine.APIEngine.runMethod(SourceFile:230)

at com.comsol.clientapi.impl.GeomSequenceClient.run(SourceFile:499)

Caused by: Exception:
com.comsol.util.exceptions.FlException: Invalid property value
(rethrown as com.comsol.util.exceptions.FlException)
Messages:
Invalid property value

Invalid property value.
- Property: p

'Control points' is a matrix of real numbers.
- : Expected size is 2 (0 2147483647).
- : Expected unit is: m.
- Property: p (Control points)


at com.comsol.clientapi.engine.c.handleException(SourceFile:27)

at com.comsol.client.interfaces.g.a(SourceFile:378)

at com.comsol.client.interfaces.ClientWebSocketCommandManager.a(SourceFile:485)

at com.comsol.client.interfaces.g.processCommandAnswer(SourceFile:334)

at com.comsol.client.interfaces.g$d.e(SourceFile:534)

... 5 more

Caused by: Exception:
com.comsol.util.exceptions.FlException: Invalid property value
Messages:
Invalid property value.
- Property: p

'Control points' is a matrix of real numbers.
- : Expected size is 2 (0 2147483647).
- : Expected unit is: m.
- Property: p (Control points)


at com.comsol.nativeutil.properties.Property.k_(SourceFile:1053)

at com.comsol.nativeutil.properties.Property.d(SourceFile:1046)

at com.comsol.nativeutil.properties.v.check(SourceFile:701)

at com.comsol.nativeutil.properties.Property.getValidDoubleMatrix(SourceFile:553)

at com.comsol.model.internal.impl.PropValueImpl.getDoubleMatrix(SourceFile:747)

at com.comsol.model.internal.impl.PropFeatureImpl.O(SourceFile:2990)

at com.comsol.model.internal.impl.PropFeatureImpl.doGetDoubleMatrix(SourceFile:2907)

at com.comsol.model.internal.impl.PropFeatureImpl.getDoubleMatrix(SourceFile:1945)

at com.comsol.geommesh.geom.PrimBezierPolygon.f(SourceFile:328)

at com.comsol.geommesh.geom.PrimBezierPolygon.doExecute(SourceFile:357)

at com.comsol.geommesh.geom.s.a(SourceFile:616)

at com.comsol.geommesh.geom.s.execute(SourceFile:855)

at com.comsol.model.method.GeomFeatureMethod.build(SourceFile:860)

at com.comsol.model.method.GeomSequenceMethod.build(SourceFile:1944)

at com.comsol.model.method.GeomSequenceMethod.b(SourceFile:1827)

at com.comsol.model.method.GeomSequenceMethod.run(SourceFile:1781)

at com.comsol.model.internal.impl.GeomSequenceImpl.l(SourceFile:4124)

at com.comsol.model.internal.impl.GeomSequenceImpl$21.a(SourceFile:3277)

at com.comsol.model.internal.impl.GeomSequenceImpl$21.execute(SourceFile:1)

at com.comsol.model.clientserver.ClientManager$1.call(SourceFile:169)

at java.util.concurrent.FutureTask.run(FutureTask.java:266)

at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)

at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)

at java.lang.Thread.run(Thread.java:745)


Error in run (line 96)
evalin('caller', [script ';']);


what is the problem !!!

Thank you
Best regards

4 Replies Last Post Apr 26, 2017, 5:51 a.m. EDT
Lars Gregersen COMSOL Employee

Please login with a confirmed email address before reporting spam

Posted: 7 years ago Apr 25, 2017, 7:29 a.m. EDT
Hi

Please post your script so we can have a look.


--
Lars Gregersen
Comsol Denmark
Hi Please post your script so we can have a look. -- Lars Gregersen Comsol Denmark

Please login with a confirmed email address before reporting spam

Posted: 7 years ago Apr 25, 2017, 7:41 a.m. EDT
Hello,
Hereby you find the matlab file.
thank you so much
Hello, Hereby you find the matlab file. thank you so much

Lars Gregersen COMSOL Employee

Please login with a confirmed email address before reporting spam

Posted: 7 years ago Apr 26, 2017, 5:08 a.m. EDT
Hi

The M-file you posted is quite long. The lines that doesn't work are for a component "b2" that is later deleted so I assume that these lines are not that important. You can try to delete the lines that refer to "b2" and see how it goes. I've tried - it doesn't really work smoothly.

The reason is that the script you export from Comsol by default includes all steps you have performed when working with the model. Hence it includes all the times you have solved the model.

Assuming that you just want to work with the final model and the final result there is a smarter way.

Before saving the model as an M-file select File->Compact History. The resulting file will be much shorter and should be easier to work with.

Do you really need to use the entire M-file? It can be nice to have the M-file in order to learn about the syntax for changing settings in a model, but as this post highlights - it is often much easier to work with a saved MPH-file and simply change the parts you wish to change when you simulate using Matlab.


--
Lars Gregersen
Comsol Denmark
Hi The M-file you posted is quite long. The lines that doesn't work are for a component "b2" that is later deleted so I assume that these lines are not that important. You can try to delete the lines that refer to "b2" and see how it goes. I've tried - it doesn't really work smoothly. The reason is that the script you export from Comsol by default includes all steps you have performed when working with the model. Hence it includes all the times you have solved the model. Assuming that you just want to work with the final model and the final result there is a smarter way. Before saving the model as an M-file select File->Compact History. The resulting file will be much shorter and should be easier to work with. Do you really need to use the entire M-file? It can be nice to have the M-file in order to learn about the syntax for changing settings in a model, but as this post highlights - it is often much easier to work with a saved MPH-file and simply change the parts you wish to change when you simulate using Matlab. -- Lars Gregersen Comsol Denmark

Please login with a confirmed email address before reporting spam

Posted: 7 years ago Apr 26, 2017, 5:51 a.m. EDT
Thank you so much it works for me now.
I want to export all the results from the model to Matlab that's why I thought to work with Matlab file.
Is there any method to export all the results from Comsol to Matlab

Best regards
Thank you so much it works for me now. I want to export all the results from the model to Matlab that's why I thought to work with Matlab file. Is there any method to export all the results from Comsol to Matlab Best regards

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.