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 newbie here, (user of Mathcad Prime 10.0)
I wanted to ask if anyone can explain how to use normal Iteration in Mathcad. Like, I have different equations and I want to create 5 loops or "intervals" to get my answer.
I always used "solve block" for iteration, but now this won't work.
I want to create something like this:
I tried asking AI but it only gave me nonsense. I never used this type of Iteration on Mathcad before, only on Excel.
Thanks for any help. Sorry if I wrote a little bit wobbly, English is not my native language.
Best regards,
Saro : )
Solved! Go to Solution.
I honestly had nothing better than this picture of equations I have to use to get the answer, every example of tutors has the same mistake of values, so I thought maybe that’s the way it has to be written. I know it was not the best example, sorry for that. Even the Excels that they use have the same mistake.
Our tutors tell us to use Excel, but I know that Mathcad should be able to do it to. They just don’t teach us Mathcad, sadly. I tried to use the solve-block, because I really didn’t know how to use intervals in Mathcad. Mine never gave me an answer. I also tried to use the table method with matrix but it never showed anything, since I didn’t use the “i”. All that knowledge I got from helpdesk, but nothing ever worked.
I wrote “i=0..6 but this didn’t really do anything. I think it’s a special “i” that I have to figure out.
Thank you for your replay, I appreciate it.
You don't show which differential equation(s) you intend to solve.
Why do you think that a solve block with "odesolve" does not work? Show us what you have tried to do.
Do you really need the intermediate steps as shown in your picture or wouldn't the final result, a numeric solution function, suffice?
I would suggest that you set up a worksheet as far as you can get and post it here.
BTW, the table your picture shows indicates that "A" should be of unit meter - shouldn't it be m² ? Otherwise there would be a unit mismatch!
Furthermore, if g should be the constant of gravity, h.g would not be dimensionless but rather would be a length (e.g. with unit meter)
Your picture does not show the values of "s" and "m" and "Q". I suspect that it should be s=0.7 meter, m=2.3 and Q=7.318 m³/s (approx.), correct?
Addendum
If you really would need the exact table your picture shows, one way to achieve that is the usage of a range variable:
The differences in the values may be due to me not guessing the values for s, m and Q totally correct.
BTW, even though its possible to do so, its not a good idea to name variables the same as predefined constants or units. I am talking about the usage of variable names like "m" and "s" which correspond to the units 'meter' and 'seconds'.
Once the vectors of values are created you can combine them into a table if that's needed.
To calculate the values of Rm, etc. which are shown in the right column in your picture, you would need a different range variable "j" which starts at 1 because the calculation of these values use the index i-1. Doing so will set the element with index 0 (which is never calculated) to zero.
Here for example the calculation of vector "Rm":
Werner, you are literally a genius. This looks definitely correct, but I was never able to set the "i". I always wrote it, but nothing happened. Everything showed up as an Error. And the values have been written like that on every Excel or page of tutors, so I thought this might need to be written like that. But you are correct "A" is "m²" and so on.
I also didn't know that for the "Rm" I have to use a new vector. So thank you.
I will try to figure out how to put the "i" and "j" so that Mathcad sees them as vector elements.
I thank you so much!! This is so helpful. I appreciate you : )
There is nothing special about the "i". It just a normal name used for a range variable.
You type i:0..6 and that all. You may also specify the second value by typing i:0,1..6 but if no second value is provided, Prime automatically assumes a step width ( = second value minus first value) of 1. See -> Range Variables
The range variable can now be used to create the necessary data vectors.
Not that the range name "i" is used as vector/matrix index, NOT as literal index!! See -> Index Operator
The reason I suggested a different range for Rm etc. is because their calculation access an element with index i-1. As "i" starts with zero, this would mean that you would be trying to access an element with index -1 which does not exist and so you would get an error.
To be able to solve the ODE using a solve block with odesolve you would have to provide the ODE in the usual math notation.
I attach the Prime 10 sheet for your reference.
These where kind of my first attempts, I also tried solve-block, but quickly realized it won't work, since it's mainly used to find variables in an equation. After a bit of digging in the PTC guidelines for Mathcad, I realized there is a function for vectors. That's why my "i" was wrong. Now I know where it is, and it worked. Thank you. Also thank you for showing me how to make it look like a table. I always wrote: table= stack (A, R, v, etc.). It was always an Error.
But everything works now:
I still have another question for something similar. But I will first try to figure it out myself
Thank you very much again.
Best regards,
Saro
I can't easily extract your problem from the picture, there are a lot og undefined terms.
Mathcad has always had the ability to implement a step-wise solutions; calculating the next state of a set of parameters from the preceding values. Attached is a simple example. The equation in yellow is the magic.
I honestly had nothing better than this picture of equations I have to use to get the answer, every example of tutors has the same mistake of values, so I thought maybe that’s the way it has to be written. I know it was not the best example, sorry for that. Even the Excels that they use have the same mistake.
Our tutors tell us to use Excel, but I know that Mathcad should be able to do it to. They just don’t teach us Mathcad, sadly. I tried to use the solve-block, because I really didn’t know how to use intervals in Mathcad. Mine never gave me an answer. I also tried to use the table method with matrix but it never showed anything, since I didn’t use the “i”. All that knowledge I got from helpdesk, but nothing ever worked.
I wrote “i=0..6 but this didn’t really do anything. I think it’s a special “i” that I have to figure out.
Thank you for your replay, I appreciate it.