Community Tip - If community subscription notifications are filling up your inbox you can set up a daily digest and get all your notifications in a single email. X
Hello,
Is it possible to return a string vertically rather then horizontally? I'm guessing this takes some programming, but I haven't been able to figure it out. What I'm trying to do is to somehow get "Return" to have the same dimensions "Output", as indicated below.
Thanks for any help!.
Solved! Go to Solution.
Not sure what you would like to see as result!?
A string is not a vector or matrix, so you can't transpose it and there is no way to show a string vertically.
The best I could think of is to create a vector with the single letters as elements. Not sure if this would meet your needs and what it could be good for.
Anyway here its in MC15 but it should work the very same in Prime:
I do it... as a picture
Not sure what you would like to see as result!?
A string is not a vector or matrix, so you can't transpose it and there is no way to show a string vertically.
The best I could think of is to create a vector with the single letters as elements. Not sure if this would meet your needs and what it could be good for.
Anyway here its in MC15 but it should work the very same in Prime:
Hi Werner,
Thank you for your help, I think your suggestion on the right will work perfectly!
I'm on Prime 3.1, any suggestions as to why I'm getting the error. Sorry if I'm asking basic questions...
And if you're curious, I'm using MathCAD to perform mathematical processing that I'm exporting to an external database for further processing. I'll be augmenting the vertical strings to additional results (matrices) that will execute particular commands.
Would have been nice if you provided the error message .
Building this in Mathcad 11 gives:
Where the error message is: "This function needs more arguments".
It relates to the usage of the stack() function, that requires more than a single parameter (in Mathcad 11).
I guess it's the same problem in Prime.
You can solve it with this:
Where the brackets immediately around v.i, the argument of the vec2str() function, are the brackets of a vector.
One way to get that is with the following trick:
This gives you an array of 1 element.
Now copy the part to the right of the = sign of the last expression, and put that as the argument to vec2str() in the program, and next replace the 0 with v.i and you're done.
But in Prime you should be able to create an empty, one-element vector using the matrix constructor 'Insert Matrix', or just CTL-M.
Success!
Luc
No, my guess was wrong. Prime allows a single argument to stack(), and allows a single-element vector as argument to vec2str():
So, what is the error message you get from Prime?
Luc
Hi Luc,
Thanks for your insights and it was foolish of me not to include the error message (sorry). The message I'm getting is, "This variable is undefined. Check that the label is set correctly." (see below). There must be something I haven't defined?
Responding to your post; My sheet's ORIGIN is globally set to 0, so I'm not understanding why I would need the ORIGIN trick. And if I need to use the Matrix function in the equation, would you mind demonstrating as I"m not seeing how to insert it.
Thanks!
Adrian
Adrian,
I think you get the error because you've used a literal subscript rather than an index for v (and maybe as well for vs).
Contradictory to my post above, you need to type "v[i" rather than "v{tick 'Subscript' in the ribbon}i".
The first gives you an index into the array v, which shows as follows when the cursor is on it:
Note the "[" in gray, indicating that i is in the subscript of v, which is what you want here, and you need the same for vs.
The second gives you a variable named v{subscript}i, which shows as follows:
Your error message shows as this one, hence my conclusion. The vector "v" is a known variable, "v{subscript}i" (which is normally referred to as v.i since in Mathcad (not Prime) you can enter it by typing "v.i").
Also not how much lower the i is with respect to vs and v in the Werner's sheet below.
You don't specifically need ORIGIN as the first part of the index list, unless you want your function to be generally usable independent on the actual setting of ORIGIN. I usually write my functions such that they're independent on the actual value of ORIGIN.
Success!
Luc
Hi Luc,
You're right!!!
I wasn't aware of the array index functionality and making that change is all the difference!
Thanks for your help!
Adrian
You're welcome.
I'm on Prime 3.1, any suggestions as to why I'm getting the error.
Unfortunately I don't know. Maybe its a labeling mismatch as the error message you posted later says. Its hard to say without seeing the sheet.
I tried it with Prime 3.0 and it all worked as supposed (and I don't think that the problem is with version 3.1):
Your variable "Output" is a n x 1 vector consisting of valid ASCII codes?
I attach the sheet in P30 format.
And if you're curious, I'm using MathCAD to perform mathematical processing that I'm exporting to an external database for further processing. I'll be augmenting the vertical strings to additional results (matrices) that will execute particular commands.
But if you write the strings letter by letter (probably by using WRITETEXT?) you will not get rid of the quote signs. Do you really want them in your command file? Otherwise it probably would be a better idea to directly write the vector with the ASCII codes in binary mode. Of course you would have to insert CR LF (code 13 and 10) after every character but this could easily be achieved automatically by a small MC program.
Hi Werner,
Thanks for the programming insight!
Combining your suggestion with Luc's enabled the result I was looking for!
This is huge for my processing!!!
Adrian
You are welcome!
Glad you finally got what you were looking for.