Matlab Help: Verify Equality of Expressions with Vectors

  • Thread starter alexparker17
  • Start date
  • Tags
    Matlab
In summary, the conversation was about a Matlab assignment and creating a vector and verifying expressions. The attempt at a solution involved using the log function and encountering an error with the inverse function due to a non-square matrix. The conversation also mentioned the requirements for a matrix to have an inverse.
  • #1
alexparker17
1
0
Matlab Need urgent Help

Homework Statement


Create an appropriate vector 'x' and verify the equality of Right and Left hand sides of the expressions given above.


Homework Equations



Doing this by a/A=1 & b/B=1

The Attempt at a Solution



What i have done so far. But keep on getting this error at the bottom. Any help would be great


>> syms x
>> x=-10:1:10;
>> A=log(x+sqrt(x.^2.+1))

A =

Columns 1 through 13

-2.9982 -2.8934 -2.7765 -2.6441 -2.4918 -2.3124 -2.0947 -1.8184 -1.4436 -0.8814 0 0.8814 1.4436

Columns 14 through 21

1.8184 2.0947 2.3124 2.4918 2.6441 2.7765 2.8934 2.9982

>> B=log(x+sqrt(x.^2.-1))

B =

Columns 1 through 6

-2.9932 + 3.1416i -2.8873 + 3.1416i -2.7687 + 3.1416i -2.6339 + 3.1416i -2.4779 + 3.1416i -2.2924 + 3.1416i

Columns 7 through 12

-2.0634 + 3.1416i -1.7627 + 3.1416i -1.3170 + 3.1416i 0 + 3.1416i 0 + 1.5708i 0

Columns 13 through 18

1.3170 1.7627 2.0634 2.2924 2.4779 2.6339

Columns 19 through 21

2.7687 2.8873 2.9932

>> a;
? Undefined function or variable 'a'.

>> A;
>> a=(exp(x)-exp(-x))/2;
>> b=(exp(x)+exp(-x))/2;
>> inv(a)
? Error using ==> inv
Matrix must be square.
 
Physics news on Phys.org
  • #2

FAQ: Matlab Help: Verify Equality of Expressions with Vectors

1. How do I use the "isequal" function in Matlab to verify equality of expressions with vectors?

The "isequal" function in Matlab compares two expressions or variables and returns a logical value of 1 if they are equal, or 0 if they are not equal. To use this function, simply type "isequal(expression1, expression2)" in the command window, where expression1 and expression2 are the two expressions you want to compare.

2. Can I use "isequal" to compare multiple expressions at once?

Yes, the "isequal" function can be used to compare multiple expressions at once. Simply separate each expression with a comma within the parentheses, for example: "isequal(expression1, expression2, expression3)".

3. What happens if the expressions I am comparing have different dimensions?

If the expressions have different dimensions, the "isequal" function will return a logical value of 0, indicating that they are not equal. This is because the dimensions of the expressions must also match for them to be considered equal by the function.

4. Is there a way to ignore the dimensions of the expressions when using "isequal"?

Yes, you can use the "isequaln" function in Matlab to ignore the dimensions of the expressions. This function compares the values of the expressions without considering their dimensions, and will return a logical value of 1 if they are equal, or 0 if they are not equal.

5. Can I use "isequal" to compare expressions with different data types?

Yes, the "isequal" function in Matlab can compare expressions with different data types. However, it is important to note that the data types must be compatible in order for the function to return a logical value of 1. For example, a numerical expression and a string expression cannot be considered equal by the "isequal" function.

Similar threads

Replies
3
Views
1K
Replies
1
Views
1K
Replies
10
Views
2K
Replies
3
Views
1K
Replies
1
Views
1K
Replies
1
Views
2K
Back
Top