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 was asked to create a function called mydrawing in Matlab to draw or plot lines...
I was asked to create a function called mydrawing in Matlab to draw or plot lines onto a graph, using a so called pen. The pen will start at the origin and will move along the +ve horizontal axis. The pen is also supplied with a list of commands in a form of a string, to draw or plot the lines onto the graph. The string commands are: 1) 'F' : the pen moves forward by x = 1.0 2)...
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 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 am trying to understand a few injection molding calculations. I will appreciate your assistance. How...
I am trying to understand a few injection molding calculations. I will appreciate your assistance. How do I calculate part weight for plastic injection molding? Is it mass * density or volume * density? My part is 29.126 grams and I am using  Polypropylene (PP) which has a density of 0.899 g/cm3 . Therefore : 29.126 * 0.899= 26.184 grams To convert to ounce: 26.184* 1/28.3495=0.9236 ounce Is the above correct? How do I calculate shot weight?  Please explain clearly and give...
I am trying to understand a few injection molding calculations. I will appreciate your assistance. How...
I am trying to understand a few injection molding calculations. I will appreciate your assistance. How do I calculate part weight for plastic injection molding? Is it mass * density or volume * density? My part is 29.126 grams and I am using  Polypropylene (PP) which has a density of 0.899 g/cm3 . Therefore : 29.126 * 0.899= 26.184 grams To convert to ounce: 26.184* 1/28.3495=0.9236 ounce Is the above correct? How do I calculate shot weight?  Please explain clearly and give...
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...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT