Question

6. [15] In this question you will write a user-defined function, which contains one sub-function. Create a vector t with exac

Please use Matlab for coding and good commentary please.
Thank you.

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

Hi,

Please find the answer below;


%%%Driver Function

function [] = main()
%main function
%declare variables
n1=3;
n2=4;
figure
%Invoking the function with paramters
graphFunction(n1,n2);
end


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function [] = graphFunction(n1,n2)
%animation3
%t vector with points
t=linspace(0,200,2001);
%for loop to plot
for i = 1:length(t)
    %calculate x,y,z
    x=t(i);
    y=1-t(i);
    z=t(i)^2;
    %check if x is divisible by n1 and n2
    if rem(x,n1)==0 && rem(x,n2)==0
        plot3(x,y,z,'-o','Color','r','MarkerSize',15);
        hold on;
        grid on;
        pause(0.001);
    end
    plot3(x,y,z,'-o','Color','b');
    hold on;
    grid on;
    %plot labels
    xlabel('x(t)')
    ylabel('y(t)')
    zlabel('z(t)')
end
end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

D Х Figure 2 File Edit View Insert Tools Desktop Window Help Search Documentation Sign In N CU *104 X 4 3 z(t) 1 0 50 De w 20

Add a comment
Know the answer?
Add Answer to:
Please use Matlab for coding and good commentary please. Thank you. 6. [15] In this question...
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 MATLAB for all coding with good commenting. (20) Consider the function f(x) = e* -...

    Please MATLAB for all coding with good commenting. (20) Consider the function f(x) = e* - 3x. Using only and exactly the four points on the graph off with x-coordinates -1,0, 1 and 2, use MATLAB's polyfit function to determine a 3' degree polynomial that approximates f on the interval (-1, 2]. Plot the function f(x) and the 360 degree polynomial you have determined on the same set of axes. f must be blue and have a dashed line style,...

  • PLEASE USE MATLAB COMMANDS THANK YOU Use Matlab to graph the functions f(x) = 3xsin(3x) and...

    PLEASE USE MATLAB COMMANDS THANK YOU Use Matlab to graph the functions f(x) = 3xsin(3x) and g(x)= 12 - 2x² so that you can read off the point(s) of intersection (if any), accurate up to two decimal places. 1) Write down the Matlab command(s) you used to create the x-vector. 2) Write down the Matlab command(s) you used to produce the vectors containing the f- and g-function values. 3) Write down the Matlab command(s) you used to plot the graphs....

  • Please use Matlab and good commenting. 106/); [15] A particular sequence has the recursive formula In+3...

    Please use Matlab and good commenting. 106/); [15] A particular sequence has the recursive formula In+3 = In+1 +sin(tn) where n = 0,1,2,3,... and we have that to = 3.t1 = 1. Use a loop to calculate the first 10000 terms of the sequence. Then display these term values as red circles on a graph. The figure must have a title and axes labels. A table, with headings, must then be created with the first column showing the value of...

  • Using MATLAB!!! Please and thank you (5 points) Use Matlab to plot the magnitude and phase...

    Using MATLAB!!! Please and thank you (5 points) Use Matlab to plot the magnitude and phase of as a function of ω over the interval 0 If the input is ω 2π (5 points) What is the FS representation of y[n]? (5 points) Plot x[n] and y[n] over the range 0 to 24. If either has an imaginary component you must plot both real and imaginary parts .You must hand in a published .pdf of your script that shows the...

  • MATLAB, Please answer question 1. + ENGR 102 Homework 9 :- 1) An elliptical staircase that...

    MATLAB, Please answer question 1. + ENGR 102 Homework 9 :- 1) An elliptical staircase that decreases in size with height can be modeled by the parametric equations: r cos(t) y-rsint) it m) Where, e-0.04t Ib cos(O)+ [a sin()]- a and b are the semimajor and semiminor axes of the ellipse, h is the staircase height, and n is the number pf revolutions that the staircase makes. Make a 3-D plot of the staircase with a 20 m, b 10...

  • Please answer question on MATLAB showing work and the script. Thank you. Create a function M-ile...

    Please answer question on MATLAB showing work and the script. Thank you. Create a function M-ile that will implement a for loop to perform the tollowing tasks for a random input array, tt x. Count how many elements are greater than an arbitrary integer and display these values as well as the count using fprintf. loop to perform the following tasks Create a function M-ile that will implement a for l for a random input array, x. Calculate the arithmentic...

  • Please use MATLAB programming as this is what we use for class thank you. 39. The...

    Please use MATLAB programming as this is what we use for class thank you. 39. The following MATLAB commands create a sine-sha ped signal y(t) that contains random noise: t = 0: .05:10; y sin (t)-0.1+0.2 rand (1,length (t)) Write a MATLAB program that uses these commands to create a noisy sine-shaped signal. Then the program smooths the signal by using the three- points moving-average method. In this method the value of every point i except the first and last,...

  • 1) a) Write MATLAB function that accepts a positive integer parameter n and returns a vector...

    1) a) Write MATLAB function that accepts a positive integer parameter n and returns a vector containing the values of the integral (A) for n= 1,2,3,..., n. The function must use the relation (B) and the value of y(1). Your function must preallocate the array that it returns. Use for loop when writing your code. b) Write MATLAB script that uses your function to calculate the values of the integral (A) using the recurrence relation (B), y(n) for n=1,2,... 19...

  • Please use matlab, post the code, and dont just write the code by hand. Thank you!...

    Please use matlab, post the code, and dont just write the code by hand. Thank you! 4 [3 points] Use the function f(x on the interval [5, 5] and the 11 points below to find a N-10 Lagrange polynomial, using MATLAB. You will need to write code for and plot the polynomial as a function of x, but you do not have to write the polynomials down by hand 5 0 2 3 4 5 f(x) | 0.0399 | 00623...

  • use matlab and show all codes and work the question continues from this 4. Write a...

    use matlab and show all codes and work the question continues from this 4. Write a function with header (A, V - myCone (r, h), which outputs the total area A and volume of a cone with base radius r and height h. 5. Write a function - myMatrix (myvec, m, n) which creates an m-by-n matrix A, as in Problem 3, but for arbitrary values of mand n and any length of vector myvec. Hint: the function can use...

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