Community Tip - Stay updated on what is happening on the PTC Community by subscribing to PTC Community Announcements. X
Is there a way of defining the number of matrix rows and columns just by say setting up a function? i.e. if I want a 5x5 matrix I can just type 5 and 5 in two functions and the matrix will auto generate
Solved! Go to Solution.
If you are referring to a matrix with empty placeholders, unfortunately not.
yes, then you can enter your data. is the only way to add or delete lines is by clicking on the matrix tab again? if so thats pretty poor
So you are referring to Prime??
Try Shift-Enter and/or Shift-Tab to add rows and columns. (one of the very few things which are more convenient in Prime than in Mathcad).
As Werner has stated above there are shortcuts to add and remove columns/rows, but I don't there is a way to automatically create an empty matrix.
Mike Armstrong wrote:
As Werner has stated above there are shortcuts to add and remove columns/rows, but I don't there is a way to automatically create an empty matrix.
But its easy with a to create a matrix of any dimensions which consists of all zeros.
Just type M[5,5:=0 and you have created your 5x5 matrix.
Werner Exinger wrote:
Mike Armstrong wrote:
As Werner has stated above there are shortcuts to add and remove columns/rows, but I don't there is a way to automatically create an empty matrix.
But its easy with a to create a matrix of any dimensions which consists of all zeros.
Just type M[5,5:=0 and you have created your 5x5 matrix.
Yes we have that option, but that is no good if we want a 5x5 matrix with empty placeholders, for say a user input.
Mike Armstrong wrote:
If you are referring to a matrix with empty placeholders, unfortunately not.
We don't know which version of Mathcad or Prime the question is related to.
I didn't know it could be done in either.
Mike Armstrong wrote:
I didn't know it could be done in either.
In MC15 an below you create a matrix with empty placeholders by typing Ctrl-M and then typing in ther number of rows and columns. In Prime you will have to use the mouse and "Insert matrix" and are limited to 12x12. Otherwise you will have to use the menu or Shift with Enter or space (and it depends on which of the two shift keys you use wheter you insert above or below, to the left or to the right).
I haven't fully understood the question as of the two functions the PO mentioned and it was not clear to me if he wants to create a matrix with empty placeholders or a matrix filled with values depending on function(s).
Werner Exinger wrote:
Mike Armstrong wrote:
I didn't know it could be done in either.
In MC15 an below you create a matrix with empty placeholders by typing Ctrl-M and then typing in ther number of rows and columns. In Prime you will have to use the mouse and "Insert matrix" and are limited to 12x12. Otherwise you will have to use the menu or Shift with Enter or space (and it depends on which of the two shift keys you use wheter you insert above or below, to the left or to the right).
I haven't fully understood the question as of the two functions the PO mentioned and it was not clear to me if he wants to create a matrix with empty placeholders or a matrix filled with values depending on function(s).
Thanks Werner,
I was aware we had external keyboard shortcuts available, but I thought the question was referring to creating a blank matrix at worksheet level. Maybe we need some clarification 🙂
Mike Armstrong wrote:
Werner Exinger wrote:
Mike Armstrong wrote:
I didn't know it could be done in either.
In MC15 an below you create a matrix with empty placeholders by typing Ctrl-M and then typing in ther number of rows and columns. In Prime you will have to use the mouse and "Insert matrix" and are limited to 12x12. Otherwise you will have to use the menu or Shift with Enter or space (and it depends on which of the two shift keys you use wheter you insert above or below, to the left or to the right).
I haven't fully understood the question as of the two functions the PO mentioned and it was not clear to me if he wants to create a matrix with empty placeholders or a matrix filled with values depending on function(s).
Thanks Werner,
I was aware we had external keyboard shortcuts available, but I thought the question was referring to creating a blank matrix at worksheet level. Maybe we need some clarification 🙂
Yes, thats necessary. From the screenshot he sent it looks like your assumption (empty placeholders) was right. But I still don't see how this would be beneficial and what Gareth had in mind when he wrote about the "two functions" in his initial post.
Werner Exinger wrote:
Yes, thats necessary. From the screenshot he sent it looks like your assumption (empty placeholders) was right. But I still don't see how this would be beneficial and what Gareth had in mind when he wrote about the "two functions" in his initial post.
I have no idea what was meant by "two functions". However, I had thought about this issue in the past.
In my work we write a load of programs with multiple inputs, say for calculating pipeweights or pipeline stability. I tend to write them in a way so that they are 'fool proof' and in the past wanted an option for the user to select the required number of pipeline variations or number of stability runs.
They could make the selection and then an empty vector / matrix would be created and all they had to do was fill in the blanks.
Mike Armstrong wrote:
Werner Exinger wrote:
Yes, thats necessary. From the screenshot he sent it looks like your assumption (empty placeholders) was right. But I still don't see how this would be beneficial and what Gareth had in mind when he wrote about the "two functions" in his initial post.
I have no idea what was meant by "two functions". However, I had thought about this issue in the past.
In my work we write a load of programs with multiple inputs, say for calculating pipeweights or pipeline stability. I tend to write them in a way so that they are 'fool proof' and in the past wanted an option for the user to select the required number of pipeline variations or number of stability runs.
They could make the selection and then an empty vector / matrix would be created and all they had to do was fill in the blanks.
I understand, but its hard anyway to make Mathcad sheets foolproof. It would mean to make the inputs via scripted opjects and then you can't use units.
The best you could do is create a matrix consisting of all zeros or all NaN's or, maybe the best option, all elements consisting of a strring (either empty or some meaningful text).
Mike,
Similiar to what I'm trying, I've wrote a mathcad file and I'm trying to make it easier as possible for the guys which will be using it. I can just add columns and rows via ctrl+m but was trying to make it "fool proof"
How did you create the matrix from options that what the user put in as you've mentioned?
Werner,
I will try M[5,5:=0 method, could this be done with variables. regarding the functions I stated just ignore this as this was something what someone mentioned and I wasn't quire sure what they meant either.
Werner,
I will try M[5,5:=0 method, could this be done with variables. regarding the functions I stated just ignore this as this was something what someone mentioned and I wasn't quire sure what they meant either.
Yes, you can use variables here. In case M is alreade a matrix you can precede that command by M:=0 to be sure the matrix is deleted.
Mathcad has a convenient mechanism that if you assign a matrix element a value and the matrix is not big enough, it will enlarge the matrix and fill all extra elements with 0.
As I already wrote in another answer here, you can create any matrix with any dimensions and any initial values you like. You will have to use a small function to do so:
And of course you could also use the built in function "matrix" to do so:
Another option which comes to mind (apart from using scirpted components for more foolproff user input) is to use from the menu "insert-data-table".
The user decides while he is typing in the data abou the size of the resulting matrix and is even able to expand or shrink the matrix later.
The point is that using whatever method you can only create valid Mathcad objects and a term with empty placeholders is not (yet) valid.
Gareth Bradley wrote:
Is there a way of defining the number of matrix rows and columns just by say setting up a function? i.e. if I want a 5x5 matrix I can just type 5 and 5 in two functions and the matrix will auto generate
Sure you can do that. But what do you mean with "just type 5 and 5 in two functions"?
Could it be that the command "matrix" is what you are looking for?
Otherwise you will have to provide an example of what exactly you are after.
Gareth Bradley wrote:
As attached.
So this seems to be Mathcad 15 or below?
And what exactly is it want you want to do? Obviously you know how to create a matrix with empty placeholders by typing Ctrl-M and you can add or delete rows and columns via Ctrl-M, too.
As Michael already said its not possible to create a matrix with empty placeholders via a command in a program and I honestly can't see any benefit if we would be able to do so.
But you can easily create any type of matrix using a function filled with any values you wish.
apologies guys, this is on mathcad 14
Gareth Bradley wrote:
apologies guys, this is on mathcad 14
I already assumed "real Mathcad" from the picture.
An what about your needs? Its still unclear what exactly you are trying to do. Any expression with an empty placeholder is not a valid Mathcad object and so can't be created by a function.
Will M[5,5:=0 do the job for you (you may of course use variables instead of the scalars 5, too)?
It appears that what I'm trying to achieve is not possible on mathcad. I'm trying to create the matrix of a given size (5x5) with blank placeholders. using variables to define the number of rows and columns. from the replys, yes i can create a matrix using ctrl+M but this is not what I'm trying to achieve.
I also do not want to infill the placeholders with any given numbers just create the matrix with blank placeholders created by variables
Richard I have a feeling this is exactly where he is after. Where have you been hiding this little beauty?
I just created it, based on some components Tom wrote.
Richard Jackson wrote:
I just created it, based on some components Tom wrote.
Superb work
Great! Very interesting sheet, indeed!
Richard Jackson wrote:
Here's an improved version.
Indeed it is. Pre-selecting the rows and columns above might be a better
Agree. But if you use text boxes, you can enter and edit the number of rows and columns even faster and better. Don't you think ?