You are on page 1of 15

>> A=[1 - 1 3;

2 0 4;
-1 - 31];
Error using vertcat
Dimensions of matrices being concatenated are not
consistent.

>> A=[1 - 1 3;
2 0 4;
-1 - 3 1];
Error using vertcat
Dimensions of matrices being concatenated are not
consistent.

>> A=[1 -1 3;
2 0 4;
-1 -3 1];
>> B=[1 2 3 4; -1 0 2 -3; -3 1 -6 2];
>> C=[ 1 2 3;4 5 6;7 8 9];
>> A*B

ans =

-7

5 -17

-10

8 -18

-1

-1 -15

13
16
7

>> C^3+A

ans =

469

575

687

1064

1305

1552

1655

2031

2413

>> (A'*B)'

ans =

-4

-5

13

15

-4 -10

11
2

>> u=[3 - 1 5 6];


>> B=[1 2 3 4; -1 0 2 -3; -3 1 -6 2;u];
Error using vertcat
Dimensions of matrices being concatenated are
not consistent.

>> u=[3 -1 5 6];


>> B=[1 2 3 4; -1 0 2 -3; -3 1 -6 2;u];
>> B

B=

-1

-3

-3

-6

-1

>> [V,v]=eig(B)

V=

Columns 1 through 2

0.0487 + 0.0000i -0.3888 + 0.0000i


0.3923 + 0.0000i 0.3679 + 0.0000i
-0.8517 + 0.0000i -0.0112 + 0.0000i
0.3440 + 0.0000i -0.8446 + 0.0000i

Columns 3 through 4

-0.7120 + 0.0000i -0.7120 + 0.0000i


-0.2320 - 0.5708i -0.2320 + 0.5708i
0.2812 - 0.1624i 0.2812 + 0.1624i
0.0641 + 0.0620i 0.0641 - 0.0620i

v=

Columns 1 through 2

-7.0966 + 0.0000i 0.0000 + 0.0000i


0.0000 + 0.0000i 7.8827 + 0.0000i
0.0000 + 0.0000i 0.0000 + 0.0000i
0.0000 + 0.0000i 0.0000 + 0.0000i

Columns 3 through 4

0.0000 + 0.0000i 0.0000 + 0.0000i


0.0000 + 0.0000i 0.0000 + 0.0000i
0.1069 + 1.9392i 0.0000 + 0.0000i
0.0000 + 0.0000i 0.1069 - 1.9392i

>> format short


>> [V,v]=eig(B)

V=

Columns 1 through 2

0.0487 + 0.0000i -0.3888 + 0.0000i


0.3923 + 0.0000i 0.3679 + 0.0000i
-0.8517 + 0.0000i -0.0112 + 0.0000i
0.3440 + 0.0000i -0.8446 + 0.0000i

Columns 3 through 4

-0.7120 + 0.0000i -0.7120 + 0.0000i


-0.2320 - 0.5708i -0.2320 + 0.5708i
0.2812 - 0.1624i 0.2812 + 0.1624i
0.0641 + 0.0620i 0.0641 - 0.0620i

v=

Columns 1 through 2

-7.0966 + 0.0000i 0.0000 + 0.0000i


0.0000 + 0.0000i 7.8827 + 0.0000i
0.0000 + 0.0000i 0.0000 + 0.0000i
0.0000 + 0.0000i 0.0000 + 0.0000i

Columns 3 through 4

0.0000 + 0.0000i 0.0000 + 0.0000i

0.0000 + 0.0000i 0.0000 + 0.0000i


0.1069 + 1.9392i 0.0000 + 0.0000i
0.0000 + 0.0000i 0.1069 - 1.9392i

>> det(A)

ans =

>> det(C)

ans =

6.6613e-16

>> format short


>> det(C)

ans =

6.6613e-16

>> format long


>> det(C)

ans =

6.661338147750939e-16

>> format
>> help format

format Set output format.


format with no inputs sets the output format to the default appropriate
for the class of the variable. For float variables, the default is
format SHORT.

format does not affect how MATLAB computations are done.


Computations
on float variables, namely single or double, are done in appropriate
floating point precision, no matter how those variables are displayed.
Computations on integer variables are done natively in integer. Integer
variables are always displayed to the appropriate number of digits for
the class, for example, 3 digits to display the INT8 range -128:127.
format SHORT and LONG do not affect the display of integer variables.

format may be used to switch between different output display formats


of all float variables as follows:
format SHORT

Scaled fixed point format with 5 digits.

format LONG

Scaled fixed point format with 15 digits for double

and 7 digits for single.


format SHORTE

Floating point format with 5 digits.

format LONGE

Floating point format with 15 digits for double and

7 digits for single.


format SHORTG

Best of fixed or floating point format with 5

digits.
format LONGG

Best of fixed or floating point format with 15

digits for double and 7 digits for single.


format SHORTENG Engineering format that has at least 5 digits
and a power that is a multiple of three
format LONGENG Engineering format that has exactly 16 significant
digits and a power that is a multiple of three.

format may be used to switch between different output display formats


of all numeric variables as follows:

format HEX
format +

Hexadecimal format.
The symbols +, - and blank are printed

for positive, negative and zero elements.


Imaginary parts are ignored.
format BANK
format RAT

Fixed format for dollars and cents.


Approximation by ratio of small integers. Numbers

with a large numerator or large denominator are


replaced by *.

format may be used to affect the spacing in the display of all


variables as follows:
format COMPACT Suppresses extra line-feeds.
format LOOSE Puts the extra line-feeds back in.

Example:
format short, pi, single(pi)
displays both double and single pi with 5 digits as 3.1416 while
format long, pi, single(pi)
displays pi as 3.141592653589793 and single(pi) as 3.1415927.

format, intmax('uint64'), realmax


shows these values as 18446744073709551615 and 1.7977e+308 while
format hex, intmax('uint64'), realmax
shows them as ffffffffffffffff and 7fefffffffffffff respectively.
The HEX display corresponds to the internal representation of the value
and is not the same as the hexadecimal notation in the C programming
language.

See also disp, display, isnumeric, isfloat, isinteger.

Reference page in Help browser


doc format

>> format shortg


>> det(C)

ans =

6.6613e-16

>> det(A)

ans =

>> det(C)

ans =

6.6613e-16

>>
>> rec(A)
Undefined function 'rec' for input arguments of type 'double'.

>> orth(A)

ans =

-0.59106

0.088255

-0.77532

-0.3364

-0.22255

0.93757

>> null(A)

ans =

-0.8165
0.40825
0.40825

>> orth(B)

ans =

-0.45162

-0.26885

0.79949

-0.29082

0.054838

0.49652

0.46404

0.73153

0.43017

-0.78836

0.13066

0.41996

-0.77973

-0.2443

-0.35834

0.45158

>> null(B)

ans =

Empty matrix: 4-by-0

>> orth(C)

ans =

-0.21484

0.88723

-0.52059

0.24964

-0.82634

-0.38794

>> null(C)

ans =

-0.40825
0.8165
-0.40825

>> t=0:0.1:4*pi;
>> y=sin(t);
>> plot(x,y) grid on
hold on
plot(x,y) grid on
|
Error: Unexpected MATLAB expression.

>> t=0:0.1:4*pi;
>> y=sin(t);
>> plot(t,y) grid on
hold on
plot(t,y) grid on
|
Error: Unexpected MATLAB expression.

>> plot(t,y)
grid on hold on
Error using grid
Too many input arguments.

>> plot(t,y) grid on


plot(t,y) grid on
|
Error: Unexpected MATLAB expression.

>> t=0:0.1:4*pi;
>> y=sin(t);
>> plot(t,y)
grid on
hold on
>>
>>
>>
>> t=-2*pi:0.1:2*pi;
y=cos(t);
plot(t,y)
grid on
hold on
>> t=-2*pi:0.1:2*pi;
y=cos(t);
plot(t,y)
grid on
hold on
>>
>>
>>
>> x=-5:0.02:5;
>> y=x^2-3*x-2;
Error using ^
Inputs must be a scalar and a square matrix.
To compute elementwise POWER, use POWER (.^) instead.

>> y=x.^2-3*x-2;
>> plot(x,y)
>> plot(x,y)
>> x=-5:0.02:5;

>> y=x.^2-3*x-2;
>> z=x.^3-2*x+1;
>> figure(2)
>> subplot(2,1,1)
plot(x,y,'g-')
grid on
hold on
subplot(2,1,1)
plot(x,y,'b--')
grid on
hold on
>> x=-5:0.02:5;
y=x.^2-3*x-2;
z=x.^3-2*x+1;
figure(2)
subplot(2,1,1)
plot(x,y,'g-')
grid on
hold on
subplot(2,1,2)
plot(x,y,'b--')
grid on
hold on
>>
>>
>>
>>
>> G1=tf(1,[200 0 0])

G1 =

------200 s^2

Continuous-time transfer function.

>> G2=([1 1],[1 4 0 0])


G2=([1 1],[1 4 0 0])
|
Error: Expression or statement is incorrect--possibly
unbalanced (, {, or [.

>> G2=tf([1 1],[1 4 0 0])

G2 =

s+1
----------s^3 + 4 s^2

Continuous-time transfer function.

>> series(G1,G2)

ans =

s+1
----------------200 s^5 + 800 s^4

Continuous-time transfer function.

>> G=feedback(ans,1)

G=

s+1
------------------------200 s^5 + 800 s^4 + s + 1

Continuous-time transfer function.

>> polos(G)
Undefined function 'polos' for input arguments of type 'tf'.

>> polos(tf(G))
Undefined function 'polos' for input arguments of type 'tf'.

>> pole(G)

ans =

-3.9999 +

0i

0.13325 +

0.13928i

0.13325 -0.13327 +
-0.13327 -

>> zero(G)

ans =

-1

>> step(G)

0.13928i
0.12602i
0.12602i

grid on

You might also like