Skip to main content
1-Visitor
April 26, 2013
Solved

working with vectors in a program

  • April 26, 2013
  • 13 replies
  • 5299 views

Hi everyone, I'm having lots of issues with one program I'm doing, and I would like to ask if you can help me with one in particular.

I'm trying to pick up a number from a vector compare it with some value and then do an iteration, but for some reason Mathcad doesn't let me pick up the number from the vector.

I'm trying to do:

Clipboard04.jpg

but it seems that I cannot use this kind of statement in an iteration.

Thx in advance.

PS: I'm Spanish so excuse me if my english it's a little bit rough

Best answer by Werner_E

I tried to edit the foregoing post and insert a pic but got repeatedly an error "null" ??

So here it is:

26.04_3.png

Is this in the range of what you tried to do?

BTW, I think that you felt in the trap of thinking that Mathcad would take the variables which are calculated and defined in the sheet before the routine in some other parts of your routine, too (K22). K23 is OK as you never define a local variable with that name.

13 replies

Werner_E
25-Diamond I
April 26, 2013

Not sure what the problem is?

v.return is a matrix consisting of four vectors, each containing 21 3*1 vectors.

Where do you try to pic a number from (which?) vector??

BTW, this

26.04.png

doesn't seem to make any sense!?

Another thing I noticed:

26.04_2.png

As soon as K1 gets 0 the first time it will never change that value again. Is this what should happen? Or did you had in mind that the local K1 should get the value of the variable K1 outside if the program whenever the condition is fulfilled? In the latter case you would have to rename one of the K1, as Mathcad will always take the "nearest" K1 it will find - tha tis the local one if it exist (which is the case after the first assignment).

1-Visitor
April 26, 2013

BTW, this

26.04.png

doesn't seem to make any sense!?

no you're right, but this it's only because the program isn't finished yet and I have to figure out a couple of things more.

Another thing I noticed:

26.04_2.png

As soon as K1 gets 0 the first time it will never change that value again. Is this what should happen? Or did you had in mind that the local K1 should get the value of the variable K1 outside if the program whenever the condition is fulfilled? In the latter case you would have to rename one of the K1, as Mathcad will always take the "nearest" K1 it will find - tha tis the local one if it exist (which is the case after the first assignment).

I thought that Mathcad checks each step if the condition is fullfilled and if it is it takes the first definition of K1 because the vaules of x are changing each step.

Despite all of this, the problem I was talking about was with the definition of Fi+1, I want to make a simple calculus with a scalar number, I mean obtain a diferent value of Fi+1 each step but mathcad tells me that it has to be a matrix, and I don't get it.

THX

Werner_E
25-Diamond I
April 26, 2013

Another thing I noticed:

26.04_2.png

As soon as K1 gets 0 the first time it will never change that value again. Is this what should happen? Or did you had in mind that the local K1 should get the value of the variable K1 outside if the program whenever the condition is fulfilled? In the latter case you would have to rename one of the K1, as Mathcad will always take the "nearest" K1 it will find - tha tis the local one if it exist (which is the case after the first assignment).

I thought that Mathcad checks each step if the condition is fullfilled and if it is it takes the first definition of K1 because the vaules of x are changing each step.

What do you mean by "first definition"? The one outside of the program? No, it will only take it the very first time the line K1 <--- .... is executed. From then on in the iteration mathcad will take the internal variable K1 anf if this is set to zero in one step, it will stay zero for all succeeding steps. The vector x changes in each step, but why do you think this would affect K1? K1 is not calculated in your routine. It is either set to K1 (which makes sense only the very first time) or set to zero.

Despite all of this, the problem I was talking about was with the definition of Fi+1, I want to make a simple calculus with a scalar number, I mean obtain a diferent value of Fi+1 each step but mathcad tells me that it has to be a matrix, and I don't get it.

But there is no code in your file showing this attempt!? Fi+1 is a 3x1 vector, not a scalar.