Small Help in MatLap ( square matrix ? )

In summary, the conversation is about a beginner in MATLAB seeking help on plotting a discrete function involving arrays and the element-by-element power operator. The main issue is that the matrix must be square, and the user is directed to use the .^ operator instead of the ^ operator. A link to MATLAB documentation is also provided.
  • #1
ahmedking
2
0
Small Help in MatLap ( square matrix ?!? )

>> n=-5:0.01:17;
>> u=1;
>> x=0.7^n*u(n);
? Error using ==> mpower
Matrix must be square.

how can i solve this problem

as iam a beginner in the matlap :)the main question is

plot the following discrete functions

1- x[n]=0.7^n*u[n] -5<n<17

please help me thanks in advance
 
Physics news on Phys.org
  • #2


please help i need it urgently :)
 
  • #3
ahmedking said:
how can i solve this problem

as iam a beginner in the matlap :)
I'm pretty sure you mean matlab.
ahmedking said:
>> n=-5:0.01:17;
>> u=1;
>> x=0.7^n*u(n);
? Error using ==> mpower
Matrix must be square.
Your variable n is an array, so you need to use the element-by-element power operator, which is .^

Also, you are setting u to 1 in the second line, above, but u appears to be an array in the third line. You're going to run into another problem with u(n), since the index of an array has to be an integer >= 1. IOW, the value of n must be an integer >= 1 in an expression u(n).

Here's a link to some documentation on MATLAB. I have found it to be pretty helpful.
http://www.mathworks.com/access/helpdesk/help/pdf_doc/matlab/getstart.pdf
ahmedking said:
the main question is

plot the following discrete functions

1- x[n]=0.7^n*u[n] -5<n<17

please help me thanks in advance
 

Related to Small Help in MatLap ( square matrix ? )

1. What is a square matrix?

A square matrix is a type of matrix in linear algebra that has an equal number of rows and columns. This means it has the same number of elements in each row and column, and can be represented by a square grid.

2. How do I create a square matrix in MatLab?

To create a square matrix in MatLab, you can use the built-in function "eye(n)" where "n" is the desired size of the matrix. This will create a square matrix with "n" rows and columns, with values of 1 on the main diagonal and 0 everywhere else.

3. How do I access specific elements in a square matrix?

To access specific elements in a square matrix, you can use indexing. For example, to access the element in the 2nd row and 3rd column, you would use the notation "matrix(2,3)". This will return the value at that specific location in the matrix.

4. Can I perform mathematical operations on square matrices in MatLab?

Yes, you can perform various mathematical operations on square matrices in MatLab such as addition, subtraction, multiplication, and division. However, it is important to note that the two matrices involved must have the same dimensions in order for the operation to be valid.

5. How can I check if a matrix is a square matrix in MatLab?

To check if a matrix is a square matrix in MatLab, you can use the built-in function "issquare(A)" where "A" is the matrix in question. This will return a logical value of true if the matrix is square, and false if it is not.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
3K
  • Linear and Abstract Algebra
Replies
2
Views
1K
  • Programming and Computer Science
Replies
2
Views
1K
  • Linear and Abstract Algebra
Replies
5
Views
2K
  • Calculus and Beyond Homework Help
Replies
1
Views
1K
  • Math Proof Training and Practice
Replies
8
Views
2K
  • Differential Equations
Replies
7
Views
801
  • MATLAB, Maple, Mathematica, LaTeX
Replies
10
Views
1K
Back
Top