Question

Question4 The six lines below from MATLAB script contain coding mistakes that will cause errors. P and explain those mistakes and propose corrections. 2.5 Marks Answer: x [-12-3 7]: % this line is correct! x(-3) 3; Plot(x): 96 uestion 5 2.5 Marks Give the display result in the command window for each command MATLAB Commands Displayed results 1 y xsqrt(-1); 2 x- roots([1 1 -6]) 3 a poly(12 -3) 4 Cl1 1-6 polyval(c, 1)
0 0
Add a comment Improve this question Transcribed image text
Answer #1

question 4

x=[-1 2 -3 7]%this line is correct
%x(-3)=3; This line is wrong. x(-3) is wrong. Subscript must be an integer.
x(3)=3;
%z=x*x //This line is wrong. For element by element multiplication, .* must be used.
z=x.*x;
%plot(x) //This line is wrong. For discrete time vector, stem is the plot command line path
stem(x);

Command window:

x =

-1 2 -3 7

x =

-1 2 3 7

z =

1 4 9 49

Question 5

x=-i; %i=sqrt(-1)
y=x*sqrt(-1); %(-i)*(i)=-((i)^2)=-(-1)=1
x+y %-i+1=1-i

questlon 4 x [-12-3796this line is correct %x(-3):3; This line is wrong. x(-3) is wrong-subscript must be an integer. x(3) 3; %-хХ //This line is wrong. For element by element multiplication, ., must be used. %plot(x) //This line is wrong.For discrete time vector, stem is the plot command-line-path stem(x -2 1.5 2 2.5 3.5 Command window: 12-37 1237 14949

Add a comment
Know the answer?
Add Answer to:
Question4 The six lines below from MATLAB script contain coding mistakes that will cause errors. P...
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
  • matlap Question 1 1. Consider the following Matlab program 5 - (2 < 3) & (C2...

    matlap Question 1 1. Consider the following Matlab program 5 - (2 < 3) & (C2 > 3) 1 (1 - 0)) What is the final value of s? A. True B. *1 CO D. false 2- Which expression tests whether variable x is between (but not the same as) the values 5 and 10 (a) 5 <x< 10 (b) 5 <= x <= 10 (c) 5 < X & X > 10 (d) x < 10 & 5 <...

  • Solve it using matlab and there is an example for a similar one i put •...

    Solve it using matlab and there is an example for a similar one i put • Write a function calculate_mean_ci(). The inputs to this function are of the form (x, sigma, level). These are x: a numeric vector. sigma : population standard deviation. level : the confidence level given as a percentage, e.g., 95. • The output is a vector of length two of the form (lwr, upr), where lwr = - 20.025 4 and upr = 1 + 20.025...

  • Unable to correct errors from my MatLab Script and would like to see a script to...

    Unable to correct errors from my MatLab Script and would like to see a script to compare mine to. Write a MatLab script that simulates a virus spread. This problem needs the following parts, some of which are nested loops, ie Part 3, 4 and 5 are nested in Part 2’s loop (for or while): To build the program first to only deal with infection transmission within the town’s neighbors An array which for every person in the town which...

  • This is a MATLAB Question. Below is my base code for a Fourier Series of a...

    This is a MATLAB Question. Below is my base code for a Fourier Series of a half triangle wave. So I am being asked to isolate the first 8 components so that only those first 8 components of the half triangle function are calculated by MATLAB fft function, and then afterwards I am asked to do the same thing but with the first 20 components rather than the first 8. How do I isolate the first x number of components...

  • Please help me correct my MATLAB script code for this problem, thank you!! A projectile PA is launched from point A towards the east with an initial launch velocity voa and an initial...

    Please help me correct my MATLAB script code for this problem, thank you!! A projectile PA is launched from point A towards the east with an initial launch velocity voa and an initial lauw angle of 0x. The impact point of the projectile Pa is a point B in a valley with an ordinate, yon, located below the clevation of point A. The launch from point A is instantaneously detected at point B, and a counter projectile P launched simultaneously...

  • Objective : Write a C Shell script which copies all files(*.java and *.class) from your home dire...

    Objective : Write a C Shell script which copies all files(*.java and *.class) from your home directory to a new one, and Analyze the new directory information such as number of files, user permissions, and disk usage. Sample Output:                                                    << CS Directory Analysis >>      Date:   ============================================================ Current Directory: /home/tomss New Directory Created : /home/tomss/pgm01 File information Total Number of files : 22 files Directory files:   0 files Plain text files:   10 files File have read permissions: 3 files File have...

  • okay so here is my c++ code and the errors im really stuck on fixing what...

    okay so here is my c++ code and the errors im really stuck on fixing what i did wrong it seems to be the same repeated error our job is to write a menu driven program that can convert to display Morse Code ere is the menu the program should display Menu Alphabet Initials N-Numbers - Punctuations S = User Sentence Q- Quit Enter command the user chooses A your program should use a loop and your morse code printing...

  • You need not run Python programs on a computer in solving the following problems. Place your...

    You need not run Python programs on a computer in solving the following problems. Place your answers into separate "text" files using the names indicated on each problem. Please create your text files using the same text editor that you use for your .py files. Answer submitted in another file format such as .doc, .pages, .rtf, or.pdf will lose least one point per problem! [1] 3 points Use file math.txt What is the precise output from the following code? bar...

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