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

Community Tip - Learn all about PTC Community Badges. Engage with PTC and see how many you can earn! X

## Help me  5-Regular Member

## Help me

hi, I am new using mathcad prime, I have a couple of questions that I would like to help me. I'm sorry for the writing or if you do not understand what I write, my English is basic.
I was working the next function (see attached image)

I would like to add the value of ΦPn_max and 0 to the end of the result of the functions ΦPn and ΦMn respectively, so that the graph closes with the y axis

1 ACCEPTED SOLUTION

Accepted Solutions  24-Ruby V
(To:LemnosOreoda)

Yes, you can't do that with ranges and given the limit use of ranges thats not a real drawback.

Ranges always produce  equally spaced continuous values.

16 REPLIES 16  23-Emerald III
(To:LemnosOreoda)

Welcome to the forum!

Please attach the worksheet. And state which version of Prime you are using.

A picture can tell a thousand words... A worksheet tells infinitely more.

Luc  5-Regular Member
(To:LucMeekes)

A worksheet tells infinitely more ... xD
The worksheet itself does not have much, it is based on a tutorial that I saw on YouTube, on the attached sheet try to improve some things and try to program it in a different way (using vectors elaborated from conditionals besides of the functions in which the work was already). But since I pass the worksheet I will be more specific in the questions.
1. How do I add a value to c_1 (page 1), for example the value of 1, in the third position and how would it be done to place it at the end?
2. c_1 Is not considered a vector? What is it?
3. From the function f_s (i, c_1) (page 1), what is the sequence that the program follows? If I check the values ​​of ε_t the program first evaluates the values ​​of i together with the first value of c_1, before move to the next value of c_1, however the general function f_s (i, c_1) first exhausts the values ​​of c_1 before moving to the next value of i. The general sequence is what designates the order of evaluation or varies depending on whether it is a function or only the evaluation of variables?
4. Like question one, I would like to add a value to the response of a function for example to ΦMn (c_1) (page 3)
5. I would like to have, for example, the values ​​from 102 to 202 of the vector f_s (i, c_1), in another side the values ​​from 203 to 303 ...
version Prime 5.0.0.0  24-Ruby V
(To:LemnosOreoda)

1. How do I add a value to c_1 (page 1), for example the value of 1, in the third position and how would it be done to place it at the end?

You can't do that because c_1 is a range, not a vector!

2. c_1 Is not considered a vector? What is it?

Its a range. A range is sort of an implicit loop. You should use ranges for three purposes only:
- index a vector or matrix

- in program (for loop)

- for plotting to have more control than quickplot provides

BTW, I consider it a design error that in Prime ranges and vector look exactly alike when displayed

To read more about ranges vs. vectors you may check the articles of Stuart Bruff which I attached here:

Being rather old they still apply, though.

EDIT: Just noted that the pdf in the thread above is corrupt. This forum really is ... very special 😞

I attach the file here.

3. From the function f_s (i, c_1) (page 1), what is the sequence that the program follows? If I check the values ​​of ε_t the program first evaluates the values ​​of i together with the first value of c_1, before move to the next value of c_1, however the general function f_s (i, c_1) first exhausts the values ​​of c_1 before moving to the next value of i. The general sequence is what designates the order of evaluation or varies depending on whether it is a function or only the evaluation of variables?

When you define a function, what you use are so called formal parameters (formal arguments). The name of those arguments does not matter at all. So your function is the very same as , no difference. So the c_1 and i you used when defining the function have absolutely nothing to do with the variables of same name you defined right above (you probably can abandon that variable definition, unless you need them later for something else).

Evaluation of the function only takes place when you later call it, providing actual arguments For d, etc. the evaluation is using the values which where valid when you defined the function. If you changed them afterwards, this has no effect on the function outcome.

4. Like question one, I would like to add a value to the response of a function for example to ΦMn (c_1) (page 3)

No, thats a different question 😉 In question 1 you wanted to add a value to a range, which is not possible. But now you are asking for changing the output of a function. If you want to change the output of a function, you have to change the function definition. You may do this using if..else statements. E.g. "if c_1>h .... else ...."

Keep in mind that in your sheet c_1 is a range. if you call ΦMn (c_1) the result is something which looks like a vector, but isn't (its not a range,too). You can use it only for plotting (or to display the values). If you try to access the third element by typing ΦMn (c_1)[4 it will fail. If you try to assign the outcome to a variable via x:=ΦMn (c_1) it will fail. You remember: Use ranges in three situations only!

5. I would like to have, for example, the values ​​from 102 to 202 of the vector f_s (i, c_1), in another side the values ​​from 203 to 303 ...

Sorry, I don't understand that question. And  f_s (i, c_1) is not a vector!

A word of caution: The "stack" command Terry was talking about only applies to vectors, NOT ranges!  5-Regular Member
(To:Werner_E)

Spoiler

You can't do that because c_1 is a range, not a vector!

Yes i'ts correct, however I think it should be possible to apply certain simple functions for vectors to ranges without vectoring these.

Spoiler

BTW, I consider it a design error that in Prime ranges and vector look exactly alike when displayed

To read more about ranges vs. vectors you may check the articles of Stuart Bruff which I attached here:

Being rather old they still apply, though.

Thanks for the attachment and the forum link, they helped me understand how the program works

Spoiler
The name of those arguments does not matter at all.

If you evaluate the function f_s (i, c_1) for a certain value there, it does not matter the order in which the arguments are taken, but for the total set of values, if it matters, for example, you will obtain f_s' (a, b) = (a_1b_1, a_1b_2 , a_1b_3, ..., a_2b_1, a_2b_2, ...) or f_s (a, b) = (a_1b_1, a_2b_1, a_3b_1, ..., a_1b_2, a_2b_2, a_3b_2, ...)

Spoiler
Sorry, I don't understand that question. And  f_s (i, c_1) is not a vector!

I'm sorry for not letting me understand, I'll explain it differently:
I seek to know if there is a function that allows me to do the following

(see attached image)

It can ? Does that function exist?

There are more files like the one that you attached, it would help me to understand more the program ty.

Spoiler
Use ranges in three situations only!

I will remenber!  23-Emerald III
(To:LemnosOreoda)

What you want (defining a function that takes a part of a vector) is possible, but Prime does not use colon notation. You can also insert a vector: But NOTE: these functions work withy vectors only, not with range variables.

Success!
Luc  24-Ruby V
(To:LemnosOreoda)

I'm sorry for not letting me understand, I'll explain it differently:
I seek to know if there is a function that allows me to do the following

(see attached image)

It can ? Does that function exist?

Luc already showed you how to use the "submatrix" command to achieve what you are probably looking for and he also told you that this command only works on vectors.

In your picture you wrote a:=11,12..20=.. and without knowing you converted the range into a vector by doing so 😉 The evaluation (=, display the result) immediately after the definition in the same region turns the range into a vector. Thats a very old, undocumented trick, so you may decide not to use it as it may not work in future versions of Prime (IMHO thats unlikely, though). So "a" is a vector now and you could use the "submatrix" command or Luc's function "subvector" to create a vector(!) consisting of the second up to the fifth element of "a".

Note further that by default vectors are numbered beginning with 0 for the first element. So the appropriate command would be submatrix(a,1,4,0,0). You can change that behaviour by setting the system variable ORIGIN to another value, maybe by typing ORIGIN:=1 at the top of your worksheet (its also possible to do that from within the menu). Now the numbering begins with 1 and the command would be submatrix(a,2,5,1,1).

If you want to be on the safe side regardless of the value of ORIGIN you could use submatrix(a,ORIGIN+1,ORIGIN+4,ORIGIN,ORIGIN).  5-Regular Member
(To:Werner_E)

Thank you Luc and thank you Werner, is what I was looking for, but I would like to be able to do that with ranges without vectoring them but as far as I understand it is not possible.  24-Ruby V
(To:LemnosOreoda)

Yes, you can't do that with ranges and given the limit use of ranges thats not a real drawback.

Ranges always produce  equally spaced continuous values.  5-Regular Member
(To:LucMeekes)

A worksheet tells infinitely more ... xD
The worksheet itself does not have much, it is based on a tutorial that I saw on YouTube, on the attached sheet try to improve some things and try to program it in a different way (using vectors elaborated from conditionals besides of the functions in which the work was already). But since I pass the worksheet I will be more specific in the questions.
1. How do I add a value to c_1 (page 1), for example the value of 1, in the third position and how would it be done to place it at the end?
2. c_1 Is not considered a vector? What is it?
3. From the function f_s (i, c_1) (page 1), what is the sequence that the program follows? If I check the values ​​of ε_t the program first evaluates the values ​​of i together with the first value of c_1, before move to the next value of c_1, however the general function f_s (i, c_1) first exhausts the values ​​of c_1 before moving to the next value of i. The general sequence is what designates the order of evaluation or varies depending on whether it is a function or only the evaluation of variables?
4. Like question one, I would like to add a value to the response of a function for example to ΦMn (c_1) (page 3)
5. I would like to have, for example, the values ​​from 102 to 202 of the vector f_s (i, c_1), in another side the values ​​from 203 to 303 ...
version Prime 5.0.0.0  5-Regular Member
(To:LucMeekes)

A worksheet tells infinitely more ... xD
The worksheet itself does not have much, it is based on a tutorial that I saw on YouTube, on the attached sheet try to improve some things and try to program it in a different way (using vectors elaborated from conditionals besides of the functions in which the work was already). But since I pass the worksheet I will be more specific in the questions.
1. How do I add a value to c_1 (page 1), for example the value of 1, in the third position and how would it be done to place it at the end?
2. c_1 Is not considered a vector? What is it?
3. From the function f_s (i, c_1) (page 1), what is the sequence that the program follows? If I check the values ​​of ε_t the program first evaluates the values ​​of i together with the first value of c_1, before move to the next value of c_1, however the general function f_s (i, c_1) first exhausts the values ​​of c_1 before moving to the next value of i. The general sequence is what designates the order of evaluation or varies depending on whether it is a function or only the evaluation of variables?
4. Like question one, I would like to add a value to the response of a function for example to ΦMn (c_1) (page 3)
5. I would like to have, for example, the values ​​from 102 to 202 of the vector f_s (i, c_1), in another side the values ​​from 203 to 303 ...
version Prime 5.0.0.0  20-Turquoise
(To:LemnosOreoda)

Hi,

The top of the moment/axial interaction diagram can be approximated by a straight line.

Simply plot a second line between the two end points using the same plot style as the existing curve.

Cheers

Terry  5-Regular Member
(To:terryhendicott)

Hi, terryhendicott

Thanks for answering. Regarding what you tell me it is a good idea to complete the diagram. But what I want is a way to enter a value within a variable or a function already defined for example I would like to add the value one to the variable c_1(see attached image) (I say variable and not vector because since it was defined the program does not recognize it as a vector). How can I add the value 1 either where it corresponds in increasing order and how can I place it at the end or at the beginning, is this possible? All this I do in order to generalize results to be able to write something that works for other occasions.  20-Turquoise
(To:LemnosOreoda)

Hi,

You can add to the top or bottom of a vector or matrix with the "stack" command.  Look it up in help if you are unsure.

You can add more columns to a vector or matrix with the "augment" command.

Is this what you are after?

Cheers

Terry  5-Regular Member
(To:terryhendicott)

Thanks terryhendicott, that's what I was looking for. Can you also add a value not necessarily at the end of the vector?  20-Turquoise
(To:LemnosOreoda)

Hi,

Yes you can put values in order in a vector.  Use "stack" to put it at the top or bottom, then use "sort" to put the value into place.

Terry  5-Regular Member
(To:terryhendicott)

Thanks Terry, that's what I was looking for. If you can comment on the sheet I submitted and the questions I asked Luc, he is more grateful than I already am :D. 