Execute mathcad from Matlab

Hello,
We want to open, change variable and run a mathcad sheet from Matlab.
Is that possible and already exist ?.
Thanks

6 comentarios

Thomas
Thomas el 8 de Mzo. de 2017
Editada: Thomas el 8 de Mzo. de 2017
Thanks. Your code is useful but it seems I cannot get the variable to be updated. I am posting here the code and the attached mathcad file.
h = actxserver('Mathcad.Application')
h.visible=1 % make the application visible!
h.methods % these are the methods that are available at this level
h.invoke % these are the actions that can be invoked at this level
inspect(h) % more investigation of the application inteface
h.worksheet.invoke % One level down in the interface - the worksheet level
sht = h.worksheet.Open('Enter your path here .... \test.xmcd')
sht.GetValue('A') % Works !!!
val = sht.GetValue('A').Integer % Answer 5 - Works !!!
SetValue(sht,'A',7) % Does not Work - A variable is not set to 7 !!!
val = sht.GetValue('C').Integer % Should be 7+2 = 9 Does not Work !!!
Any help is appreciated on why the variable 'A' cannot be changed.
Thomas
Thomas el 21 de Mzo. de 2017
Hello All,
Finally got it to work. FOr Matlab to assign a value to a variable into Mathcad, you need to make sure that the Variable is not pre-assigned in Mathcad.
If you want Matlab to assign the value 2 to the variable A into Mathcad. Matlab will not be able to change the variable value if Mathcad has A:=1 or any other value. For Matlab to work you need A=1 or any other value or A by itself.
I am enclosing the example.
Hope this helps others.
John D'Errico
John D'Errico el 21 de Mzo. de 2017
Editada: John D'Errico el 21 de Mzo. de 2017
Geez. Is MathCad still around? I used it for a bit in the 80s. My impression at the time was it used low quality numerical algorithms. (Admittedly, it was quite new at the time.) Then when I contacted the people who wrote it, explaining the problems they had and how to fix them, they seemed to be a bit clueless about things like algorithm design, etc. Yes, that was around 30 years ago, and after a few years the software simply seemed to have disappeared. I imagine the company probably got bought out.
I'm sure that since it has somehow survived, things got better. One thing different about MATLAB is that from the very beginning I was always extremely confident the creators of MATLAB knew what they were doing.
Marie Carmen Landivar Guartatanga
Marie Carmen Landivar Guartatanga el 19 de Sept. de 2019
John, you had be surprised. At least in my branch of work, a teacher did a survey, and 7 out of 10 companies used mathcad. Only one used matlab. It depends really. My career is full of calculations with long formulas. Yes, they can be done in matlab, but mathcad offers the visual part, plus you can do simple algoriths if needed. Though, programming in mathcad is a pain compared to matlab. It depends a lot in what you are working at.
Kevin Merene
Kevin Merene el 7 de Jul. de 2021
If I wanted to get the values of an entire array rather than just a lone integer, how would I do so?

Iniciar sesión para comentar.

Respuestas (2)

Kapil Gupta
Kapil Gupta el 8 de Jul. de 2021

0 votos

I assume you want to know how you can execute mathcad from MATLAB. The following links have similar queries, you can check these out:

1 comentario

Brian Godfrey
Brian Godfrey el 10 de Ag. de 2021
Editada: Walter Roberson el 10 de Ag. de 2021
I am having an issue with MATLAB 2020a interfacing with Mathcad prime 7
I tried using your first link but I ran into an issue when trying to open a file
>> h = actxserver('Mathcad.Application')
h =
COM.Mathcad_Application
>> h.invoke
Quit = void Quit(handle, Variant(Optional))
CloseAll = void CloseAll(handle, Variant(Optional))
SetOption = void SetOption(handle, MCAppOption, Variant)
GetOption = Variant GetOption(handle, MCAppOption)
GetStringProperty = ustring GetStringProperty(handle, ustring)
GetIntProperty = int32 GetIntProperty(handle, ustring)
>> h.methods
Methods for class COM.Mathcad_Application:
CloseAll Quit delete interfaces propedit set
GetIntProperty SetOption deleteproperty invoke release
GetOption addproperty events load save
GetStringProperty constructorargs get move send
>> h.worksheet.invoke
Add = handle Add(handle)
Item = handle Item(handle, Variant(Optional))
Open = handle Open(handle, ustring)
Remove = void Remove(handle, Variant)
AddFromTemplate = handle AddFromTemplate(handle, ustring)
>> h.worksheet.methods
Methods for class Interface.CF1EB3FD_6EAB_4D71_8A1B_247F85CD2F66:
Add Open delete get release
AddFromTemplate Remove deleteproperty invoke saveobj
Item addproperty events loadobj set
>> h.worksheet.Open([pwd,'\NewDesignInputs.mcdx'])
Error using Interface.CF1EB3FD_6EAB_4D71_8A1B_247F85CD2F66/Open
Invoke Error, Dispatch Exception:
Description: Failed to open document.
any help would be greatly appreciated

Iniciar sesión para comentar.

mizomov
mizomov el 30 de En. de 2024

0 votos

1 comentario

Walter Roberson
Walter Roberson el 30 de En. de 2024
I am not at all certain, but that appears to be asking to perform certain steps within MathCad or MATLAB.

Iniciar sesión para comentar.

Categorías

Más información sobre Data Import from MATLAB en Centro de ayuda y File Exchange.

Productos

Etiquetas

Preguntada:

el 4 de Mzo. de 2017

Comentada:

el 30 de En. de 2024

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by