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

Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X

For loop question

resonator80
1-Newbie

For loop question

I am trying to get a For loop to populate a vector.
The small example I have attached doesn't work--can
somebody help?

Thanks,
Bill Edelstein
Baltimore, MD
8 REPLIES 8

Alvaro.

Alvaro,

Thanks for the hint. What I am doing is more
complicated than what I show, but your suggestion
worked.

I am presently using an old version of Mathcad 12. I
have also ordered Mathcad 14. Is Mathcad 14 better,
in your view?

Thanks again for your help,
Sincerely,

Bill Edelstein
Baltimore, MD

On 10/15/2009 11:24:34 PM, resonator80 wrote:

>I am presently using an old version of Mathcad 12. I have also ordered Mathcad 14. Is Mathcad 14 better, in your view?

In my view: Better than Mathcad 12: Yes, and a lot. But for some users, the programing style that die with mathcad 11 is more flexible and usefull. In the other hand, there are other users that probably found much easy mathcad 14 conception of things.

Because I don't have Mathcad 12 or 14, only 11, I think that I'm not the most indecated person to make more asertions.

Regards. Alvaro.

On 10/15/2009 11:24:34 PM, resonator80 wrote:
>I am presently using an old
>version of Mathcad 12. I
>have also ordered Mathcad 14.
>Is Mathcad 14 better,
>in your view?

Based on the posts on this forum since the release of version 12, a good scientific calculator was almost as good as version 12. Version 14, while not perfect, is better, and at the current discounted price ($99 US) is a good deal.

Fred Kohlhepp
fkohlhepp@sikorsky.com

The ← operator is defined as a local variable definition. Local variables exist only while a region is being calculated, and disappear upon completion of the calculation.

Your for loop does indeed calculate a vector bb. But ... bb is a local variable and so disappears at the completion of the calculation. Further ... you do not do anything with the results of the loop. You have neither an assignment (:=) to assign the result to a variable, nor an evaluation (=) to display the result. Further ... the result of a program structure (and a for loop is a program structure) is the value of the last statement executed. In your program that value is 255, the value of j1 the last time through the loop. To return bb you would need an additional statement (usually just bb) following (not in) the for loop.
__________________
� � � � Tom Gutman

On 10/15/2009 7:58:59 PM, resonator80 wrote:
>I am trying to get a For loop
>to populate a vector.
>The small example I have
>attached doesn't work--can
>somebody help?
>
>Thanks,
>Bill Edelstein
>Baltimore, MD
____________________________

This demo is for immediate results, i.e: just a function calculated from a vector of values (discretized form). Often it is not so simple as you have to carry "scalar maths" before the discretised epxort.



jmG



In Mathcad, the "for_loop" structure is very powerful and is the core construct of the programming around the inclusion of objects . In 10 years of this collab of < 85000 messages, no report of choking the Mathcad programming ... OK, OK ! before the war flames smokes from all sides.

jmG

Thanks everybody!

Bill Edelstein
Baltimore, MD
Announcements

Top Tags