Question

In: Electrical Engineering

I am trying to plot a difficult function in MATLAB, however I need to understand the...

I am trying to plot a difficult function in MATLAB, however I need to understand the basics first.

I am trying to plot

n=0

for x=0:0.01:2pi

n=n+1

y(n)=sin(x)

end

I beleive what this says, is that I want to plot sin(x) over a full period hence from o to 2pi, and I beleive the 0.01 is the incremenation along the x-axis. I am not sure what my n is doing

Could smeone please graph this for me with the MATLAB code as well, and show was you were doing and what the functions and things mean for exaple what ":" means and so on

Solutions

Expert Solution

A simple program to plot y=sin(x) is shown below

The ":" is an operator in MATLAB. It is used to represent an increament in a MATLAB expression. In this particular question, x=0:0.01:(2*pi) represents that the value of 'x' for which the sine value is caluculated. The initial vale of x=0. It is then to be incremented after each calulation. The second value of x=0+0.01; third value would be x=0.01+0.01 and so on. This means that after every calculation the value of x is incremented by 0.01. This would continue until the value of x reaches to (2*pi) which is equal to approximately 6.28.

  • Notice that a 'for' loop has not been used. 'x' is a vector containing values starting from 0 to (2*pi).
  • (2*pi) has an '*' mark in between. This represents a multiplication symbol in MATLAB. If it is not used the program may not be able to read your equation correctly.
  • The plot(x,y) command is used to plot y with respect to the values of x. Here, x is the independent variable. The independent variable always comes along the x-axis whereas the dependent variable comes along the y-axis. Do not get confused about x-axis and y-axis with vector 'x' and 'y' used in the equations.

Related Solutions

I am trying to implement a search function for a binary search tree. I am trying...
I am trying to implement a search function for a binary search tree. I am trying to get the output to print each element preceding the the target of the search. For example, in the code when I search for 19, the output should be "5-8-9-18-20-19" Please only modify the search function and also please walk me through what I did wrong. I am trying to figure this out. Here is my code: #include<iostream> using namespace std; class node {...
This is Using MATLAB: I am trying to store the solution of this matrix because I...
This is Using MATLAB: I am trying to store the solution of this matrix because I want to do something with the result like find the norm of that answer however I am stuck and cannot seem to be able to. Help would be appreciated! --------------------------------------------- MATLAB CODE: close all clear clc A = [1 -1 2 -1; 2 -2 2 -3; 1 1 1 0; 1 -1 4 5]; b = [-8 -20 -2 4]'; x = gauss_elim(A,b) function...
Assembly Question: I am trying to annotate this code and am struggling to understand what it...
Assembly Question: I am trying to annotate this code and am struggling to understand what it is doing. Can someone please add comments? .data .star: .string "*" .line: .string "\n" .input: .string "%d" .count: .space 8 .text .global main printstars: push %rsi push %rdi _printstars: push %rdi mov $.star, %rdi xor %rax, %rax call printf pop %rdi dec %rdi cmp $0, %rdi jg _printstars mov $.line, %rdi xor %rax, %rax call printf pop %rdi pop %rsi ret printstarpyramid: mov %rdi,...
I need to time series plot the following data. I am confused since there are multiple...
I need to time series plot the following data. I am confused since there are multiple sections (441, 442, 443, 444, 445, 452, 4521. This is just two years worth of the data. Year Month Period 441 442,443 444 445 448 452 4521 1992 Jan 1 1.84 1.85 1.83 0.88 2.58 2.39 2.60 1992 Feb 2 1.83 1.85 1.83 0.89 2.62 2.34 2.53 1992 Mar 3 1.87 1.90 1.83 0.88 2.63 2.35 2.53 1992 April 4 1.89 1.91 1.91 0.89...
I am trying to understand how to determine and adjust overhead costs at year end.
I am trying to understand how to determine and adjust overhead costs at year end.
I am trying to create a function in JAVA that takes in an ArrayList and sorts...
I am trying to create a function in JAVA that takes in an ArrayList and sorts the values by their distance in miles in increasing order. So the closest (or lowest) value would be first. It does not need to output the values in anyway, but it should return them so they can be output elsewhere. Please try to use the stub class below. The code for the main class is not necessary. I am only really asking for the...
I am trying to create a Box Plot chart in SPSS. Horizontal Axis is Body Mass...
I am trying to create a Box Plot chart in SPSS. Horizontal Axis is Body Mass Index and the vertical Axis is body frame (small, medium, large). I would like to add in gender to show the difference in BMI and body frame, but haven't been able choose the correct steps to do that. Can you help me?
I need to set up and run a goodness of fit test. I am trying to...
I need to set up and run a goodness of fit test. I am trying to learn more about the type of novels that people prefer to read. Please include null and alternative hypotheses. Show all work and please explain if you use any excel tests. Total number of responses is 30. Romance: 18 Sci - Fi: 7 Fiction: 5
I am trying to do edge detection using matlab. I have posted code here. It does...
I am trying to do edge detection using matlab. I have posted code here. It does not give any error but it's not running it at all. So please help me to fix it and also exaplin each line of this code pls. Thanks! i = imread('C:\Users\Amanda\Desktop"); I = rgb2gray(1i); BW1 = edge(I,'prewitt'); BW2= edge(I,'sobel'); BW3= edge(I,'roberts'); subplot (2,2,1); imshow(I); title('original'); subplot(2,2,2); imshow(BW1); title('Prewitt'); subplot(2,2,3); imshow(BW2); title('Sobel'); subplot(2,2,4); imshow(BW3); title('Roberts');
What I am trying to do is to design a Butterworth Bandpass filter using Matlab, High...
What I am trying to do is to design a Butterworth Bandpass filter using Matlab, High frequency must equal to 16 Hz and lower frequency must be 10Hz (passBand). and the input signal must be a white noise signal. here is my code : mu=0; sigma=2; X= sigma*randn(500,1)+mu; %Generating White Noise signal Fs=500;%Sampling Frequency Fh= 16; Fl=10; order=6; [b,a]=butter(order,[Fh Fl]/(Fs/2),'bandpass');%Butterworth BandPass filter XX=filtfilt(b,a,X);%filter the signal both forward and backword in time Actually, I am not sure about Fs value that...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT