MATLAB!
Evaluate the function y=(x-(1/x))/(1+(1/x^2)) for x varying from -2 to 2 with 0.01 steps. Plot the function (y versus x) as a line such that it's blue when y<-0.2, red when y<0.2, and green for all the other values.
% Matlab script to plot the function (y versus x) as a line such that it's blue when y<-0.2, red when y<0.2, and green for all the other values.
% define the x vector
x = (-2:0.01:2);
% calculate the y vector
y=(x-(1./x))./(1+(1./x.^2));
% use find function to get the indexes for y < -0.2 , y >=
-0.2 and y < 0.2
% and y >= 0.2
idx1 = find(y < -0.2);
idx2 = find( y >= -0.2 & y < 0.2);
idx3 = find(y>=0.2);
% create a new vectors for x and y to contain all the points to
be shown
% with blue line, red line and green line respectively
xBlue = x;
yBlue = y;
xRed = x;
yRed = y;
xGreen = x;
yGreen = y;
% set the points in xBlue which belong to red or green line to
NaN so that
% it is not plotted
xBlue(idx3) = NaN;
xBlue(idx2) = NaN;
yBlue(idx3) = NaN;
yBlue(idx2) = NaN;
% Similarly, set the points in xRed which belong to blue or
green line to NaN so that
% it is not plotted
xRed(idx3) = NaN;
xRed(idx1) = NaN;
yRed(idx3) = NaN;
yRed(idx1) = NaN;
% Similarly, set the points in xGreen which belong to red or bue
line to NaN so that
% it is not plotted
xGreen(idx1) = NaN;
xGreen(idx2) = NaN;
yGreen(idx1) = NaN;
yGreen(idx2) = NaN;
% plot the blue line
plot(xBlue,yBlue,'b-');
hold on; % hold the current graph so that subsequent plot are
plotted in the same graph
% plot the red line
plot(xRed,yRed,'r-');
% plot the green line
plot(xGreen,yGreen,'g-');
hold off; % release the current graph
xlabel('X');
ylabel('Y');
% end of script
Output:

MATLAB! Evaluate the function y=(x-(1/x))/(1+(1/x^2)) for x varying from -2 to 2 with 0.01 steps. Plot...
Practice: Plot x vs y when y sin(x), y cosx), y sin (2"x), and y-2 sin(x) when x-1:0.1:10. Use 2 by 2 subplot, sin(x) is in location 1, cos(x) is in location 2, sin(2x) is in location 3 and 2 sin(x) is in location 4 The plot should have: (1) x labe|-"х value", y label = 'y value', legend 'y=sin(x)',' y-cos(x)',' y-sin (2*x)', "y-y-2*sin(x), and title = "X Vs. y, under Font Name of Times New Roman, and Font Size...
code in Matlab
Problem 1: The MATLAB humps function defines a curve that has 2 maxima (peaks) of unequal height over the interval 0 2, f(x) = r-0.3)2 +0.01 (r-09 +0.04 Use MATLAB to generate a plot of Kx) versus x with x [0:1/256:2: Do not use MATLAB's built-in humps function to generate the values of Rx). Also, employ the minimum number of periods to perform the vector operations needed to eneate x) values for the plo
Problem 1: The...
matlab only
Question 5: a.) Write an m-file using conditional statements to evaluate the following function, assuming that the scalar variable x has a value. The function is for x <-1 - 3e y=2+cos(m) for-1 x<5 y 10-5)+1 for r 2 5 Use your file to evaluate y for x5, x-3, and x-15, and Use keyboard entry for values of x. b.) Use a for loop in the above file to plot the above function over the interval -2x <10....
Evaluate the integral for values of x from 0 to 3 in
steps of 0.1 AND plot the integral.
The program needs to be written in Python 3. Can only
import numpy and matplotlib. CAN NOT use lambda functions or
classes of any kind.
Exercise 5.3: Consider the integral Plot of the integral from 0 to x 0.8 e: more hints You need to print E(x) with different x values. 0.6 1 Plotting the function will help The calculated values...
The function y is defined as 2exp(x) 2 + x2 exp(-x) 1 + x2 y ifx > 0 Using a for loop or otherwise, (a) Determine the values of y in a vector called z for x values from -2 to 2 in steps of 0.2. Display the values of vector z. (b) Determine and display the sum of values of the vector z.
The function y is defined as 2exp(x) 2 + x2 exp(-x) 1 + x2 y ifx...
Create a surface plot and a contour plot of the function z=(x-2)^2+2xy+y^2. Using the matlab
Matlab Problem
Plot the analytical and random walk solutions for concentration with D 0.01 att 1, 2, 5, and 10 s (four separate plots). Use an x-axis range from -2 to 2 and a y-axis range from 0 to 15e4 on all plots. Include the simulation end time in the plot title
Use Matlab to create an array x of values from 0 to 2 pi in steps of 0.1, y1 = sin(x), y2 cos(x). Plot y1 and y2 as a function of x on a single plot. Take a screen shot of your plot and include it in the word document.
In MATLAB please
Consider the nonlinear function: y = f(x) = x3 cos x a. Plot y as a function of x as x is varied between -67 and 67. In this plot mark all the locations of x where y = 0. Make sure to get all the roots in this range. You may need to zoom in to some areas of the plot. These locations are some of the roots of the above equation. b. Use the fzero...
please solve then upload matlab code
Thanks
1. The function f(z, y) (a-x)2 + b(y-12)2 is called Rosenbrock's banana function. It is often used as a benchmarking test for optimization algorithms becatse it is easy to find the minimum by hand but often very difficult to find numerically. Throughout the problem, we will use the values a = 2 and b 10. You can plot this function using the following code: x3:0.1:3; y = -10:0.2:10; Cx,Ymeshgrid(x,y); Z(2-X).2 10* (Y-X. 2)....