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

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...
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.
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...
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.
PART 5: Learn about commands used to view contents of files: use the cat command to...
PART 5: Learn about commands used to view contents of files: use the cat command to review the contents of the /home/test/passwd.bak type:   cat passwd.bak 2. now add the |more to the last command (see what happens when you push the up arrow curser key-it recalls the last command) 3. now try to cat the passwd.bak file but look at the first few lines and then the last few lines using the head and tail commands type:  head passwd.bak   and    tail...
Give the PowerShell command that would display the “Path” environment variable. What two PowerShell commands will...
Give the PowerShell command that would display the “Path” environment variable. What two PowerShell commands will display all of the users currently logged into a server? What command would give helpful information about the Get-Command cmdlet.
a) Observe the following Linux commands and work out what each command does: 1) $ ls...
a) Observe the following Linux commands and work out what each command does: 1) $ ls –al 2) $ /etc/profile 3) $ chmod 200 final_assignment.txt b) Consider a scenario where Bob has downloaded his messages to the local machine with an access of POP3, he can create mail folders and move the downloaded messages into the folders. Bob can then delete messages, move messages across folders, and search for messages (by sender name or subject). But this paradigm—namely, folders and...
Q3.  Networking commands – ping, mount, hosts, netstat The ping command can be used to check the...
Q3.  Networking commands – ping, mount, hosts, netstat The ping command can be used to check the network working condition between two systems.  You may have to find the path name of the ping command file using which or whereis command and then type the full/absolute path name of the ping command.  Issue ping command with UNIX server IP address as argument.  If the command does not stop after displaying five packets transfer and receive information, terminate the command using ctrl-c.  Otherwise, the command may...
linux Using the grep or egrep commands, what would be the full command (including regular expression)...
linux Using the grep or egrep commands, what would be the full command (including regular expression) to view only the lines in the file /boot/grub/grub.cfg that DO NOT begin with a hashtag (the # sign). In other words, what would be the command to print all the lines in this file that do not begin with this character.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT