Question

In: Computer Science

Commands are to be typed in the Command Window in MATLAB [Those preceding the symbol>> are...

Commands are to be typed in the Command Window in MATLAB [Those preceding the symbol>> are the commands]

  • 16.3 Matrix operations

    • >>a=[1 2 3;4 5 6;7 8 9]

    • >>b=[1 0 0;1 0 1;0 0 1]

  • Assigning:

    >>a=b(2,:)

  • Transposing:

    >>[1;2;3]

    >>[1;2;3]'

  • Incrementing:

    >>Tempk=a+273.15

  • Scaling:

    >>L=a*2.5

  • Adding & subtracting:

    >>[1 2 3;4 5 6]-[8 7 6;4 2 0]

  • Repeating:

    >>sqrt(a)

    >>sqrt(b)

  • Operating term by term:

  • >>[1 3;5 8].*[0 1;4 2]

  • >>[1 3;5 8]*[0 1;4 2]
  • Creating matrix efficiently

  • >>m=[364;297];

  • >>n=[3,6,4;2,9,7];

  • >>p(1,1)=3;

  • >>q=[2:2:200]

  • >>r=[1:3:20]

  • >>w=[2.5:8.5];

  • >>w=[2.5:8.5]

  • Advanced Addressing & Matrix operationso

    • >>M=[123;456;789]

    • >>M2=M(2:3,1:3)

    • >>M3=M(2:3,:)

    • >>M4=M(:,1:2)

    • >>c=[A;B]

    • >>A=[1,2;3,4]

    • >>B=[56;78]

    • >>C=[A;B]

    • >>D=[A,B]

Solutions

Expert Solution

The results of the commands when typed on MATLAB command window are provided below:

Please comment if any doubts:

Matrix operations

a=[1 2 3;4 5 6;7 8 9]

b=[1 0 0;1 0 1;0 0 1]

Output:

%Assigning

a=b(2,:)

Output:

%Transposing


[1;2;3]

[1;2;3]'

Output:

%%%Incrementing:

Tempk=a+273.15

OUTPUT:

%%Scaling:

L=a*2.5

Output:

%Adding & subtracting:

[1 2 3;4 5 6]-[8 7 6;4 2 0]

Output:

%%Repeating:

sqrt(a)

sqrt(b)

Output:

%Operating term by term:

[1 3;5 8].*[0 1;4 2]
[1 3;5 8]*[0 1;4 2]


Output:

%%Creating matrix efficiently

m=[364;297];

n=[3,6,4;2,9,7];

p(1,1)=3;

q=[2:2:200]

r=[1:3:20]

w=[2.5:8.5];

w=[2.5:8.5]


Output:

%%Advanced Addressing & Matrix operationso

M=[123;456;789]

%M2=M(2:3,1:3)%%Error , M is a M*1 array

M3=M(2:3,:)

%%M4=M(:,1:2)%%Error , M is a M*1 array

%%c=[A;B]%%Error A and B defined below this line

A=[1,2;3,4]

B=[56;78]

%%C=[A;B] %%%vertical dimensions mismatch (2x2 vs 2x1)

D=[A,B]

Note: This part contains some errors, those are commented above with reason

Output:


Related Solutions

Section 1.0: MATLAB Fundamentals Step 1.1 Open the MATLAB application Step 1.2 In the Command Window,...
Section 1.0: MATLAB Fundamentals Step 1.1 Open the MATLAB application Step 1.2 In the Command Window, type the following: x=8 % percentage sign denotes comment y=9 % variable y set to 9 x+y % add variable x + y clear %clears the workspace window clc % clears the command window Note: the % sign indicates a user comment. In the Command Window, you should see your answer : ans=17 In the Workspace window, observe "ans", "x" and "y" Step 1.3...
Write the line x = 0:2:20; in the Command Window of MATLAB and then create a...
Write the line x = 0:2:20; in the Command Window of MATLAB and then create a Simulink model that first loads x from the Workspace, then creates a vector y such that y = 2.5x + ex , and finally sends the vector y back to the Workspace. You will need a From Workspace block, a To Workspace block, two Constant blocks, a Product block, and a Sum block. Note that there is a sample time associated with the From...
Euler’s Method and Introduction to MATLAB • Start MATLAB • Inline Commands: You can type commands...
Euler’s Method and Introduction to MATLAB • Start MATLAB • Inline Commands: You can type commands directly into the command window: Type and expression and then hit enter to evaluate the expression. For example: >> 2+2 If you want to suppress the output of a command follow it with ‘;”.  For example >>2+2; Practice evaluating a few expressions in the command window. (In MATLAB multiplication is represented by * so 3*2=6). • Variables and Vectors: You can define variables in the...
Please Use matlab and show command window. Please go through all steps Using a Dialog button...
Please Use matlab and show command window. Please go through all steps Using a Dialog button with 3 buttons have the user chose one of the 3 anonymous functions below to be used in the later selected three Programmed functions (1) Integral by Trapezoidal Method,(2) Integral by Simpson Method, or (3) Root by BiSection Method.: a. f(x) = 2*x^5 -3*x^2 – 5 b. f(x) = x^2 – 5 c. f(x) = x^(1/2) 2. Using an input statement ask the user...
Open the Command Prompt window and use the nslookup command to identify the domain names that...
Open the Command Prompt window and use the nslookup command to identify the domain names that correspond to the following IP addresses: 161.170.244.20 205.251.242.103 144.160.155.43 Use the Command Prompt window and nslookup command to identify the IP addresses that correspond to the following domain names: walmart.com amazon.com att.com Close the Command Prompt window. Submit your findings.
MATLAB: Write as a script in the editor window of matlab. Quadratic roots. Write a program,...
MATLAB: Write as a script in the editor window of matlab. Quadratic roots. Write a program, quadroots.m, for finding the roots of the second- order polynomial ax2 + bx + c. Use the quadratic equation. The inputs are the coefficients a,b, and c and the outputs are z1 and z2. The program should produce (exactly) the following output in the Command window when run with (a, b, c) = (1, 2, −3):
Choose 10 commands from the list to study in detail for this assignment. For each command,...
Choose 10 commands from the list to study in detail for this assignment. For each command, you need to provide a short description of the main functionality, and an example run (including output) of the command. Notes  You need to choose at least one command from each category.  Be brief. You do not need to write a lot.  Although you are only required to document the usages of 10 commands in this assignment, you are expected to...
Research the Windows PowerShell commands for manipulating the firewall and construct a command that lists all...
Research the Windows PowerShell commands for manipulating the firewall and construct a command that lists all the firewall rules on a system with the output containing the information and headers below: Rule name TCP port Enabled
Two commands are received 5 microseconds apart. The execution time for the first command is independent...
Two commands are received 5 microseconds apart. The execution time for the first command is independent of the second and is exponentially distributed with a mean of 15 microseconds. The execution of the second command is exponentially distributed with a mean of 20 microseconds. What is the expected time from the start of execution of the first command to the completion of the second.
Use the cumsum command in MATLAB to show that the cumulative sum of an impulse is...
Use the cumsum command in MATLAB to show that the cumulative sum of an impulse is a unit step function. Add a line to your code from Problem 2. Plot the unit step function generated by the cumsum command. Turn in a copy of the code and graph.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT