Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X
Greetings colleagues of the forum, I have the following query:
How to create variable names automatically?
By programming a loop I get the names of variables but as text strings, I want to get a matrix like the one marked in red?
Is there any way to do it in Mathcad Prime 4?
I would appreciate any suggestions.
Solved! Go to Solution.
The closest you may come to is using matrix variables.
It depends on your needs if this can be useful for you.
There is a string to number function; but it will not create variable names. Short of some fancy coding (which Prime still won't do) there's no way.
Hello FredKohlhepp, thanks for your comment. I agree with what you say, I found that in Mathcad 15 there is a script to do it; but the problem is that I'm working with Mathcad Prime on this.
The closest you may come to is using matrix variables.
It depends on your needs if this can be useful for you.
Hello Werner_E, thanks for your suggestion. I had already tried it but since I have to do operations later I get an error and it does not work. However some operations can be performed.
I am reformulating my problem in other ways so as not to have to use numbered variables.
I'm just thinking out loud here, but is there any possibility of using the Custom Functions and calling C or FORTRAN code as a workaround to this problem? I've never used them, but it seems to open up some possibilities.
@DJF wrote:
I'm just thinking out loud here, but is there any possibility of using the Custom Functions and calling C or FORTRAN code as a workaround to this problem? I've never used them, but it seems to open up some possibilities.
Interesting!
I never realized that was there. Does anyone know if it could be done in Express?
In Mathcad 11, through symbolic operation, you can rename variables to a certain extent. Tom Gutman showed how to do that long ago.
As far as I know there are two ways to create new variables, one is through the user interface. If you can control the application's user interface from within executable code, you have a possibility to create new variables.
The other way is outside of the application, by manipulating the sheet file (.mcd, .xmcd or .mcdx file).
Success!
Luc