Items tagged with matrix

Feed

Hello,

To check my arguments in a procedure I need something like

myproc := proc(M :: Matrix(square, rational)

                       , N :: Matrix(shape=triangular[lower, unit], datatype = rational
                       , O :: Matrix(shape = square, dimension = 5

               )

end proc;

How does that work in Maple? What is the correct Syntax? I tried many different things that doesn't fit.

I am trying to use a do loop with if/else statements to create a 5x5 unit matrix. I made an empty array. Converted it to a matrix. Then made a do loop where I was trying to get the matrix elements where i=j to be 1 and all else to be 0. It didn't spit out a matrix.

Any advice? I assume I must have missed a small detail in syntax.


 

with(LinearAlgebra):

````

U := array(1 .. 5, 1 .. 5);

array( 1 .. 5, 1 .. 5, [ ] )

(1)

NULL

for i to 5 do for j to 5 do if i = j then U[i, j] := 1 else U[i, j] := 0 end if end do end do

U;

U

(2)

``


 

Download fail_unit_matrix_loop.mw

By the way, I am open to completely different methods, also! I was just trying to use loops to do it rather than inbuilt commands.

Pay attention to the Next Question

 

I have to find which column of a matrix contains repeated elements, i have done it in this but i'm afraid that the nested loops don't run correctly:

for j by 1 to 10 do 
for i by 1 to 30 do 
	h:=Dati[i,j];
	for x by 1 to 30 do
		
		if Dati[x,j] = h then
			if x <> i then
				return j;
				end if;
				end if;
				end do;
				 end do;
				  end do;

 

Hi everybody

In the attached file, when I run the code an error appears while calculating "omegaL1" parameter. The dimensions of the matrices are correct but the source of error is unknown to me. Can anyone help me?

Thanks in advance

R2_Link_2D.mw 

I'm trying to use subs to substitute an unknown variable with a number in a Matrix

My Matrix is called values and I have the following

change := f2:

subs(change = 5, values):

This does nothing but when I have the following, it works as expected (All f2 in the Matrix values are replaced with 5)

subs(f2,values):

I'm wondering if its trying to find and replace 'change'. If this is the case how can I get it to use whats assigned to the variable. (I've tried eval(change) but that doesn't work either)

Many thanks

does anybody know how to copy a rtable structure in a worksheet and paste it on the other worksheet?

I copy it by right click and paste on the other one but no data transfered.

Good day, I need to 2D plot from points which I get by solving numerically 17-degree equations. Firstly I take an only first solution of the equation as below, and I have a Matrix with 3 column which represents X, Y, and VALUE respectively. On the left side should be the first column ( X ), and right axis Y (2. column). As seen from Matrix X and Y getting the value between 0 and 10. Is there any option that I can plot my data in 2D?  Thanks in advance.


points := seq(seq(seq(Fun[n, i, j], n = 0 .. step), i = 0 .. step), j = 1);
Mat := Matrix((step+1)^2, 3, [points]);
         .                             X                  Y                 VALUE
           
with(plots);
pointplot3d(Mat, style = point, color = black);
 
 

Since GramSchmidt does not take Matrix as an input (I wish it did), I would like to know how to normalize a matrix rows. For example if input matrix is:

M = [  1    2]
       [  3    4]

How do I convert it into

Mn = [ 1/sqrt(5)    2/sqrt(5) ]
         [ 3/5            4/5          ]

Each row of matrix Mn has length of 1.

Thank you.

 

I am using matrices to input data in order to plot it on a surface plot. Is it then possible to export an animation of this graph rotating around an axis?

My matrix is 40 x 3 Matrix

 

Thanks :)

Assume you have a matrix A and somewhere you want to make a copy of it like B and working with them independently. Let's say you have a loop and after doing a proc on B again you have to make it equal to A. So changes on B shouldn't effect on A. What is the common way of taking such copies of A in Maple?

The following methods don't work.
 

A:=Matrix(3);
B:=A;
B(1,1):=1;
A;
A:=Matrix(3);
B:=subs(B=A,B);
B(1,1):=1;
A;

What I came up with is the following but it will look weird if one really needs to write something meaningless like *2/2.

A:=Matrix(3);
B := (1/2)*subs(B = 2*A, B);
B(1,1):=1;
A;

 

How do you recommend to calculate the square root of big Matrices (e.g, 300*300) with Maple??

My machine couldnt calculate the square root of Matrices (9*9) as you see below:


 

``

restart

Error, invalid input: with expects its 1st argument, pname, to be of type {`module`, package}, but received shareman

 

with(LinearAlgebra):

``

A := Matrix([[1, 2, 3, 4, 5, 6, 7, 8, 9], [9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9], [9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9], [9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9], [9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9]])

A := Matrix(9, 9, {(1, 1) = 1, (1, 2) = 2, (1, 3) = 3, (1, 4) = 4, (1, 5) = 5, (1, 6) = 6, (1, 7) = 7, (1, 8) = 8, (1, 9) = 9, (2, 1) = 9, (2, 2) = 8, (2, 3) = 7, (2, 4) = 6, (2, 5) = 5, (2, 6) = 4, (2, 7) = 3, (2, 8) = 2, (2, 9) = 1, (3, 1) = 1, (3, 2) = 2, (3, 3) = 3, (3, 4) = 4, (3, 5) = 5, (3, 6) = 6, (3, 7) = 7, (3, 8) = 8, (3, 9) = 9, (4, 1) = 9, (4, 2) = 8, (4, 3) = 7, (4, 4) = 6, (4, 5) = 5, (4, 6) = 4, (4, 7) = 3, (4, 8) = 2, (4, 9) = 1, (5, 1) = 1, (5, 2) = 2, (5, 3) = 3, (5, 4) = 4, (5, 5) = 5, (5, 6) = 6, (5, 7) = 7, (5, 8) = 8, (5, 9) = 9, (6, 1) = 9, (6, 2) = 8, (6, 3) = 7, (6, 4) = 6, (6, 5) = 5, (6, 6) = 4, (6, 7) = 3, (6, 8) = 2, (6, 9) = 1, (7, 1) = 1, (7, 2) = 2, (7, 3) = 3, (7, 4) = 4, (7, 5) = 5, (7, 6) = 6, (7, 7) = 7, (7, 8) = 8, (7, 9) = 9, (8, 1) = 9, (8, 2) = 8, (8, 3) = 7, (8, 4) = 6, (8, 5) = 5, (8, 6) = 4, (8, 7) = 3, (8, 8) = 2, (8, 9) = 1, (9, 1) = 1, (9, 2) = 2, (9, 3) = 3, (9, 4) = 4, (9, 5) = 5, (9, 6) = 6, (9, 7) = 7, (9, 8) = 8, (9, 9) = 9})

(1)

MatrixFunction(A, sqrt(v), v)

Error, (in LinearAlgebra:-MatrixFunction) could not compute finite interpolating value by evaluation of (1/2)/v^(1/2) at eigenvalue 0 which has multiplicity greater than one in the minimal polynomial

 

``

``

``

``

``


 

Download askkk.mw

Use the command 'matrix' to define a matrix, and how to call the first row elements of the matrix?

This method

a:=matrix([[1,2,3],[4,5,6],[7,8,9]]);

a[1..2,-2..-1], does not work? Why?

I have many linear equations as below(f,g,h,...,p, are linear of S,T,..,W):

y1=f(S[i,j],T[i,j],U[i,j],V[i,j],W[i,j]);

y2=g(S[i,j],T[i,j],U[i,j],V[i,j],W[i,j]);

y3=h(S[i,j],T[i,j],U[i,j],V[i,j],W[i,j]);

.

.

.

yn=p(S[i,j],T[i,j],U[i,j],V[i,j],W[i,j]);

Where (i,j)=(0,0),...,(I,J)

How ask Maple to write them in Matrix form as below:

AX=0

Where X is: X=Transpose{S[0,0],S[0,1],S[0,J],...,S[1,0],S[1,1],...,S[1,J],...,S[I,0],S[I,1],...,S[I,J],

                        T[0,0],T[0,1],T[0,J],...,T[1,0],T[1,1],...,T[1,J],...,T[I,0],T[I,1],...,T[I,J],...,W[I,J]}

    

1 2 3 4 5 6 7 Last Page 2 of 41