Question

MATLAB scripts are how multiple lines of code can be executed vs. entering in a line...

  1. MATLAB scripts are how multiple lines of code can be executed vs. entering in a line of code one at a time through the command window. Write a script that does the following. Only display to the console window what is specified.
    1. Creates a 4 x 10 matrix with the 1strow being 1 to 10, the 2ndrow being 11 to 20, the 3rdrow being 21 to 30, and the last row being 31 to 40.
    2. The matrix is shown on the command window, and the user is prompted to select a row of numbers.
    3. The user is prompted to select another row of numbers (it can be same row as 1stselection)
    4. MATLAB creates a 10 x 2 matrix with the 2 selected rows. The first column is the 1strow choice and the 2ndcolumn is the 2ndrow choice.
    5. The message ‘Your new matrix is’ with the matrix is shown to the command window.
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Please find the code below::

clc
clear
matrix = [1:10;11:20;21:30;31:40]

row1=input('Enter first row : ');
row2 =input('Enter second row : ');

newMatrix =[matrix(row1,:);matrix(row2,:)];
newMatrix = transpose(newMatrix)

Add a comment
Know the answer?
Add Answer to:
MATLAB scripts are how multiple lines of code can be executed vs. entering in a line...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Please provide MATLAB code and comments! Please provide MATLAB code and comments! Please provide MATLAB code...

    Please provide MATLAB code and comments! Please provide MATLAB code and comments! Please provide MATLAB code and comments! Question #5. Write a script that creates a variable called BALANCE that is assigned the value 100.00. Then prompt the user to enter an amount to withdraw. Store that amount in a variable called WITHDRAW. Use an if/else construct to display a message to the user stating whether the withdrawal was successful. If the withdrawal would result in a negative balance, state...

  • Please show the code necessary, and explanations on MATLAB. Plotting 11) Plot the function y =...

    Please show the code necessary, and explanations on MATLAB. Plotting 11) Plot the function y = sin(x) from x = 0 to 21. 12) Plot the functions y = x2 z = x2 + 2x + 1 from x = 0 to 2 on the same graph. Scripts: Input and Output 13) Write a script (M-file) to read in a message at the command line using the MATLAB input function and then display the message to the Command Window using...

  • Need Help on Matlab matrix system. Have your code return the solution x and show this...

    Need Help on Matlab matrix system. Have your code return the solution x and show this solution in a command prompt printout. Note that you can, of course, check your answer easily with the Matlab backslash command, A\b. Naive LU Decomposition Now, starting with your functioning Gauss Elimination code, modify it to keep the factors in the same matrix that it is passed. You of course will not modify the b-vector. Have this code return the L and U matrices...

  • Can you explain how this works? (cl) The following Matlab code is executed. What is Matlab's...

    Can you explain how this works? (cl) The following Matlab code is executed. What is Matlab's output? x - [0 1 2*ones(1, 4)]; b -2:3]. 2; y -x.*b; disp(y); Solution: 010 28 18

  • cope the code please thanks Write a MATLAB code to obtain the following. Keep your code...

    cope the code please thanks Write a MATLAB code to obtain the following. Keep your code commented whenever required. Copy your source code and command widow outcomes and screen shots of any plots in your solution. Generate a matrix "A" as follow. A= 16 6 8 2 10 18 12 14 4 I. II. Divide the matrix A by 2 and store the result in a matrix B. Combine matrices A & B to obtain the following matrix C. Also...

  • Using Matlab or Octave, I do not know how to write the script for this problem,...

    Using Matlab or Octave, I do not know how to write the script for this problem, please help. Must match sample output 5. Consider a 3 x 3 matrix given by A = 01 012 013 az az 633 ( dai 632 033 The trace of A is defined as tr(A)=2au. Given another 3 x 3 matrix bu bı2 bia B- bi brz bra | bgi bz2 by it can be shown that trAB') = tr(AB). Write a script that...

  • MATLAB Question: Write a script for the problem pictured. Please send the script, not just the...

    MATLAB Question: Write a script for the problem pictured. Please send the script, not just the printout. Make sure your script allows you to input a value for n so when prompted, in the command window, user types n value. The n value should be the f_k if k ==1 .... Please also send print outs if you can. BELOW IS A SAMPLE ANSWER THAT DID NOT PUT THE INPUT SCRIPT NEEDED FOR THIS QUESTION TO BE CORRECT. YOU CAN...

  • This is a matlab HW that I need the code for, if someone could help me figure this out it would b...

    This is a matlab HW that I need the code for, if someone could help me figure this out it would be appreciated. The value of t can be estimated from the following equation: in your script file, estimate the value of π for any number of terms. You must ask the user for the desired number of terms and calculate the absolute error/difference between your calculation and the built-in MATLAB value ofpi. Display your results with the following message...

  • Please code in C++. link to continue the code is this below or you can make...

    Please code in C++. link to continue the code is this below or you can make your own code if you wish(fix any mistakes if you think there are any in it): cpp.sh/3qcekv 3. Submit a header file (project3.h), a definition file (project3.cpp), a main file (main.cpp), and a makefile to compile them together. Make sure to run the command make and produce an application file and include it with your submission. For this project, you are required to create...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT