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

Repeat Matrix/vector in Mathcad

Mathcad111
11-Garnet

Repeat Matrix/vector in Mathcad

Ex:

mathcad_ques_2.JPG

1 ACCEPTED SOLUTION

Accepted Solutions

This will solve, thanks everyone for suggestions,

mathcad_ques_2+++.JPG 

View solution in original post

11 REPLIES 11

Hi,

Capture.JPG

hi, i need it in programming, like this,

mathcad_ques_2+.JPG 

maybe that way:

Werner_E_0-1655553441098.png

 

Thanks, but its not working for 'zero' 

ex:

 

mathcad_ques_2++.JPG

What did you expect to get with n=0?

 

My loop runs from 1 to n, not from 0 to n as in your pic!

Reasoning is that n means how often you want to ADD the matrix to itself.

As seen in my example with Rep(test,2) the input matrix is added zwo times, so its seem three times in the result.

There is no error check implemented in my program but of course  n=0 make no sense and the same applies to negative or non-real values.

As written above with n=0 you will get the same result as with n=1. To cope with that so you simply get the very same matrix returned with no repetition, you would have to add a simple if r < 1 and put the loop there.

Here is some error checking:

Werner_E_0-1655576833331.png

 

You can use recursion:

Fred_Kohlhepp_0-1655552615397.png

 

I can't use this approach in Mathcad 15, Pse guide & do the needful.

Hi,

Capture.JPG

Mathcad111 wrote, "I can't use this approach in Mathcad 15"

 

What I did should work in Mathcad 15.  I can no longer check it, but there is no Prime magic, this works even in Express.


 

What I did should work in Mathcad 15. 


Yes, sure it does 😉

Werner_E_1-1655577190646.png

In the last two examples the evaluation resulted in an infinite recursion, of course.

This could be avoided by exchanging the i=0 for i <=0 or for i<1 but I think that the error is OK anyway.

This will solve, thanks everyone for suggestions,

mathcad_ques_2+++.JPG 

Announcements
Check out the latest
Mathcad Tip
"PTC Mathcad 15 / Prime 1-6 Update."