Question

Matlab

Question 2. For this problem you have to create a program that defines two vectors of numbers: A and B and uses a for-loop toQuestion 2b: Problem deinition Copy the file q2a.m to q2b.m. For this problern you have to modify the code in your file so th

0 0
Add a comment Improve this question Transcribed image text
Answer #1

q2.m file:

% q2.m file A = [0:10] B = [11:20]| 2

Output of q2.m file:

A= 1 23456 78910 13 11 12 13 14 15 16 1718 19 20

q2a.txt file:

% q2a.txt [3, 6, 9, 2] C1, 5, 7, 8] C-2, 5, 6, -3] [0, 5, 7, 8] C4, 3, 2, 1] [0, 9, 8, 7]

q2a.m file:

Output for 1st row:

% q2a.m file A- [3, 6, 9, 2); for i-1:length(B) end disp(A);

Output for 2nd row:

% q2a.m file B [0, 5, 7, 8]; for i-1:length(B) end disp(A);

-2 5 6 -30 5 78

Output for 3rd row:

% q2a.m file B [0, 9, 8, 7]; for i-1:length(B) end disp(A);

q2b.m file:

Output for 1st row:

% q2b.m file A=[3, 6, 9, 2); % for reversing the contents of array B B-flip(B); for i-1:length(B) end g. for displaying the m

1

Output for 2nd row:

% q2b.m file B-Co, 5, 7, 8); % for reversing the contents of array B B flip(B); for i-1:length(B) end % for displaying the mo

Output for 3rd row:

% q2b.m file B [0, 9, 8, 7]; for reversing the contents of array B flip(B); for i-1:length(B) end % for displaying the modifi

2 0

Add a comment
Know the answer?
Add Answer to:
Matlab Question 2. For this problem you have to create a program that defines two vectors...
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
  • Question 2 Problem Definition Write a MATLAB script that uses nested loops to create a 100 by 100...

    Question 2 Problem Definition Write a MATLAB script that uses nested loops to create a 100 by 100 element 2D array representing an image that shades from white at the top to black at the bottom. Your script should save the image in a file called test2.png. Testing The image file produced should be shaded from white at the top of the image to black at the bottom of the image like SO: Coding Write your code in a MATLAB...

  • In matlab, I keep getting the same issue for this problem can someone help? "myrowproduct.m" >> Filename...

    In matlab, I keep getting the same issue for this problem can someone help? "myrowproduct.m" >> Filename myrowproduct (A,x) Undefined function or variable 'Filename' Did you mean: mfilename : myrowproduct (A, x) Undefined function or variable 'myrowproduct' function y = myrowproduct(A,x); function y my rowp roduct (A, x); Error: Function definition not supported in this context. Create functions in code file. (, 2,,)T 4. The product y Ax of an m x n matrix A times a vector x= can...

  • Part 2 to the problem in matlabthis is the hint that came with the problem

    part 2 to the problem in matlabthis is the hint that came with the problem The value of T can be estimated from the following equation: In your script file, estimate the value of t 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 (including the asterisks) where II is the number...

  • Problem Definition Write a program called process_ages that reads in an array of up to 10...

    Problem Definition Write a program called process_ages that reads in an array of up to 10 integers representing peoples ages in years and calculates and prints the maximum age and the minimum age and the average age. Your program should stop reading when either the 10th number is entered or the user enters -1. If the user enters any other negative number or a value above 150, they should be warned and prompted again for a valid age. You should...

  • The problem below is a MATLAB question, please do it only Matlab, if you are not...

    The problem below is a MATLAB question, please do it only Matlab, if you are not familiar with Matlab or not equipped with the program itself on your computer kindly leave it to someone who is. Please show me the Matlab codes for these two parts of the problem, I need to put them in same (m.file) so please consider that. Either you type the code or "preferably" you take a snip of your screen and post to teach me...

  • use MatLab to answer these questions 1. (10 points) Create an m-file called addup.m Use a...

    use MatLab to answer these questions 1. (10 points) Create an m-file called addup.m Use a for loop with k = 1 to 8 to sum the terms in this sequence: x(k) = 1/3 Before the loop set sumx = 0 Then add each term to sumx inside the loop. (You do not need to store the individual values of the sequence; it is sufficient to add each term to the sum.) After the loop, display sumx with either disp()...

  • can anyone help with a MatLab code? Problem create a function that takes in the following...

    can anyone help with a MatLab code? Problem create a function that takes in the following vector DATA and returns the number of elements, the mean and the sum of the elements. You can call the function ANALYZER DATA [2 4 5 6 7 8];

  • Solve in MATLAB Problem 3: Given the vector x- [2 1 0 6 2 3 5...

    Solve in MATLAB Problem 3: Given the vector x- [2 1 0 6 2 3 5 3 4 1 3 2 10 12 4 2 7 9 2 4 51 use a for loop to (a) Add up the values of all elements in x (b) Compute the cumulative sum, y, of elements in x You can check your results using the built-in functions sum and cumsum. Q.5 What is the value of the sum of elements in vector x?...

  • can anyone help me solve these on MATLAB?? please intro to programming and computation 3. 50...

    can anyone help me solve these on MATLAB?? please intro to programming and computation 3. 50 points - The purpose of this question is to test your ability to write for loops, so you won't get points if your answer works without using for loop. A vector is given by V - (5. 17. -3,8,0,-7. 12, 15, 20. -6, 6, 4.-7.16). Write a program as a script file that doubles the elements that are positive and raise to the power...

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