cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - When posting, your subject should be specific and summarize your question. Here are some additional tips on asking a great question. X

Matrix to vector (M2V)

I.Vos
1-Visitor

Matrix to vector (M2V)

Could someone help me to with drafting a simple short function that would be able to transform a large matrix into a vector - say M2V function.

I need one M2V function for transforming matrix rows (row by row) into a vector and other M2V for transforming matrix columns (column by column) into a vector.

I am new to Mathcad programming. At the moment my function gives me only the last row (or column). I belive that this is not a difficult task for a seasoned Mathcad user, Many thanks for your support mates.

Cheers

ACCEPTED SOLUTION

Accepted Solutions
RichardJ
19-Tanzanite
(To:I.Vos)

Here. You only need one function. Just transpose the matrix if you want rows instead of columns.

View solution in original post

21 REPLIES 21
RichardJ
19-Tanzanite
(To:I.Vos)

Here. You only need one function. Just transpose the matrix if you want rows instead of columns.

I.Vos
1-Visitor
(To:RichardJ)

Richard

Many thanks for your help! That's exactly what I need.

Could you drop me a line or two please (if yopu can) on how I could format the text (say reduce font size or change the font) of the title and axis labels in the 2D graphs. It appears that Mathcad's Help is not really helpful on the matter.

Have a good day.

Regards

I.

RichardJ
19-Tanzanite
(To:I.Vos)

Could you drop me a line or two please (if yopu can) on how I could format the text (say reduce font size or change the font) of the title and axis labels in the 2D graphs. It appears that Mathcad's Help is not really helpful on the matter.

I'm afraid Mathcad's help has nothing to say on the matter because there's no way to do that. Mathcad's graphs are rather lacking in some respects

MagnusEklund
12-Amethyst
(To:I.Vos)

Or if you want to make it independent of ORIGIN. And not use the stack( ). For some reason this is much faster.

unwrap.png

Regards,

Magnus

Magnus Eklund wrote:

Or if you want to make it independent of ORIGIN. And not use the stack( ). For some reason this is much faster.

I think because Mathcad is doing some optimization and preallocating the memory necessary for the full vector. If you force that preallocation it makes very little difference to the execution time (although there does seem to be a small improvement). When stack is used it has to reallocate memory for the vector for every column in the matrix.

Magnus

Many thanks for an interesting solution for the function that unfolds large matrix to a vector. This solution is particularly attractive since, as appears from your calculations, it processes the data quicker than the solution with the “stack” function.

My calculations operate with a data stored in a number of 12 x 24 matrices in most of cases. Therefore, implementation of your solution is preferable for improving a performance of the Mathcad worksheets that otherwise may become a bit cumbersome with slower functions. Thanks again.

It would be interesting to hear from the developers on the difference of these two solutions.

Cheers

RichardJ
19-Tanzanite
(To:I.Vos)

It would be interesting to hear from the developers on the difference of these two solutions.

It would, but the developers have never commented on anything before on the Mathcad forums, so don't hold your breath. I tihnk it's highly likely tthat the memory allocaton is at least part of it.

Just for curiosity, would you be able to attach the unzipped sheet.

Just for curiosity, would you be able to attach the unzipped sheet.

No, because this forum automatically zips the attachment when I upload it. Why can't you just unzip it?

mzeftel
12-Amethyst
(To:RichardJ)

Actually you can change the font of plot labels and titles, although it may not be apparent. Add your title and labels in the plot directly. Then go to Format > Equation and choose Math Text Font. That style sets the font characteristics for the plot titles and labels. See attached file. I did this in Mathcad 15, but I believe the capability was added in Mathcad 12 or 13. I'll ask the documentation group to add it to Help.

I.Vos
1-Visitor
(To:mzeftel)

Dear mzeftel

Many thanks for your advise on modification of the text labels at Mathcad plots. It works! At least on my machine with Mathcad 13 ... Thanks again...

By the way, one of my friends keep complaining about a "programm termination" bug in Mathcad 14 once the "print preview" button is activated. Has this issue been resoved by any chance with a patch file for version 14 or in Mathcad 15?

Kind regards

Igor V.

RichardJ
19-Tanzanite
(To:I.Vos)

By the way, one of my friends keep complaining about a "programm termination" bug in Mathcad 14 once the "print preview" button is activated. Has this issue been resoved by any chance with a patch file for version 14 or in Mathcad 15?

That's been fixed. Download and install the M020 service release if you are a single user or the M030 service release (NOT M035, which has a very bad bug!) if you are en Enterprise user.

RichardJ
19-Tanzanite
(To:mzeftel)

mzeftel wrote:

Actually you can change the font of plot labels and titles, although it may not be apparent. Add your title and labels in the plot directly. Then go to Format > Equation and choose Math Text Font. That style sets the font characteristics for the plot titles and labels. See attached file. I did this in Mathcad 15, but I believe the capability was added in Mathcad 12 or 13. I'll ask the documentation group to add it to Help.

Nice trick! I had no idea you could do that.

RichardJ
19-Tanzanite
(To:mzeftel)

Mona Zeftel wrote:

I'll ask the documentation group to add it to Help.

Actually, under "math styles" it does say "Math Text Font applies to all graph labels". I don't think anyone would look for it there though; they would look under 2D graphs.

Does this style apply to anything other than graphs? If not, I would suggest changing the name for Mathcad 15 to "Graph text font". Then there's a reasonable chnace that people will find it themselves.

Sounds like an ideal little piece for the PTC newsletter as well.

Philip

Cannot unzip because I'm currently based onsite and my works laptop doesn't have WinZIP and also restricts me from installing software.

Cheers, much appreciated.

From windows xp you don't need other software to zip or unzip folders or archives than the operating system. To restore this behavioir right-click over a zip file, choose "Open with..." and select "Carpestas comprimidas (en zip)" -this is in spanish, assumed to be "Compressed folders (in zip)"-.

Regards. Alvaro.

Cheers for the help, will save me a lot of hassle in the future.

Regards,

Mike

Click on the image.

jmG

Announcements

Top Tags