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

working with vectors in a program

SOLVED

Re: working with vectors in a program

Now I'm really scared, Mathcad desn't use the variables I've defined before the routine?

Not, if a local variable with the same name exist. It will take the "nearest" variable it finds.

Thats pretty much the same behaviour as with most programming languages

While in some programming languages you can explicitely specify the variable from which context you want to address, in Mathcad thats not possible.

But the solution is simple - just use different variable names.

One thing I haven't mentioned so far is that its inefficient to do the calculation of E.D inside the loop. As far as I can see its not dependent on anything which changes in the iteration so it should be precalculated outside of the loop, maybe even outside of the program.

Re: working with vectors in a program

27.04_2.png

awesome, absolutely right

Really!?? That way the first two components of the 3x1 vectors Fi.. never change - as the WS is written they remain zero.

The code would first copy Fi over to Fi+1 making sure that way, that Fi+1 is a 3x1 vector. Then the third component of this nev vector is changed for the scalar calculated according to your pic.

Re: working with vectors in a program

Ok, Understood.

Re: working with vectors in a program

BTW I could solve the problem with the vector and the scalar thing with that definition.

Clipboard05.jpg

Can't tell from the pic, but I hope the LHS of the last line is a F.2 and not a F[2

Announcements