input parameters from matlab

Forum for OpenSees users to post questions, comments, etc. on the use of the OpenSees interpreter, OpenSees.exe

Moderators: silvia, selimgunay, Moderators

Post Reply
Alexandros
Posts: 14
Joined: Fri May 07, 2010 4:51 pm
Location: Notre Dame

input parameters from matlab

Post by Alexandros »

Hi
in my work i need to call opensees through matlab. Althought i know how to do that (! Opensees.exe scriptname.tcl
) i do not know how to call my input parameters for opensees through matlab. For example i input a load in matlab and then i need opensees to use this value.

Thank you in advance
hugo_esquivel
Posts: 71
Joined: Fri Nov 06, 2009 6:40 am
Location: Universidad del Norte, Colombia

Re: input parameters from matlab

Post by hugo_esquivel »

If you are working on an unix-based system, then you can link matlab with opensees by using a fifo pipe... e.g. open two shells (I am using two bash shells here for simplicity)...

On shell #1, write:
% mkfifo pipe # creates a pipe file.
% echo "This message will be sent to shell #2" > pipe

On shell #2, write:
% cat < pipe
to display on screen the message sent from shell #1.

google: fifo unix for more information.

Hope it helps.
Alexandros
Posts: 14
Joined: Fri May 07, 2010 4:51 pm
Location: Notre Dame

Post by Alexandros »

Thank you for your reply.
I ll try to do that. I am familiar with unix but i do not use it that much.
Is there any other way to do it on windows system?
hugo_esquivel
Posts: 71
Joined: Fri Nov 06, 2009 6:40 am
Location: Universidad del Norte, Colombia

Post by hugo_esquivel »

I once read that the same thing could not be done on a windows system. But you might want to check the veracity of that statement since I am not entirely sure about it.
claytp
Posts: 6
Joined: Thu May 14, 2009 8:46 am
Location: Seattle, WA

Post by claytp »

What I have done (which is not nearly as sophisticated as the previous suggestion) is to use matlab to create my .tcl script using the input parameters from matlab. Then, run that script from matlab using the !OpenSees.exe command.

For example, when I create a recorder file in matlab:
fid = fopen('recorders.tcl', 'wt')
fprintf(fid, 'recorder Node -file $dataDir/DFree.out -time -dT $dTrec -node %4.0f %4.0f -dof 1 2 3 disp; \n' , freeNodes)
... lots more fprintf lines
fclose(fid)

then call "recorders.tcl" in my main .tcl model script that i will run.
Alexandros
Posts: 14
Joined: Fri May 07, 2010 4:51 pm
Location: Notre Dame

Post by Alexandros »

Thank you very much

that's exactly what i was thinking today.
Its not the most efficient way but maybe its the only way for windows.
khansoltani
Posts: 4
Joined: Mon Nov 12, 2012 2:10 pm
Location: University of Mohaghegh Ardabili

Re: input parameters from matlab

Post by khansoltani »

When I call OpenSees from a Matlab script, I face this error:

invalid command name "pattern"

While running the same code (pattern Plain 1 Linear {...}) just through the Opensees works correctly.
How can I fix it?

Thank you in advance
selimgunay
Posts: 916
Joined: Mon Sep 09, 2013 8:50 pm
Location: University of California, Berkeley

Re: input parameters from matlab

Post by selimgunay »

It may be a compatibility issue due to Matlab version. Generally running OpenSees from Matlab would slow down the analysis. A better approach is to create all the loops in tcl and run different cases directly using the for loops in tcl.
Post Reply