Question

In: Computer Science

•Try to plot these three equations in the rage of x=0 to 1 using “for” and...

•Try to plot these three equations in the rage of x=0 to 1 using “for” and “if” commands

•Y=2sin(2πx)

•Y=2cos(2πx)

•Y=log(x)

•Y=e(x)

I only know how to plot without if and for command.

no idea about using if and for command to get this figure.

Solutions

Expert Solution

`Hey,

Note: Brother if you have any queries related the answer please do comment. I would be very happy to resolve all your queries.

clc
clear all
close all
format long;
x=0:0.01:4;
y1=[];
y2=[];
y3=[];
y4=[];
for j=1:4
for i=1:length(x)
if(j==1)
y1(i)=2*sin(2*pi*x(i));
elseif(j==2)
y2(i)=2*cos(2*pi*x(i));
elseif(j==3)
y3(i)=log(x(i));
else
y4(i)=exp(x(i));
end
end
if(j==1)
figure;
plot(x,y1);
xlabel('X-values');
ylabel('Y-values');
title('Plot of 2*sin(2*pi*x)');
elseif(j==2)
figure;
plot(x,y2);
xlabel('X-values');
ylabel('Y-values');
title('Plot of 2*cos(2*pi*x)');
elseif(j==3)
figure;
plot(x,y3);
xlabel('X-values');
ylabel('Y-values');
title('Plot of 2*log(x)');
else
figure;
plot(x,y4);
xlabel('X-values');
ylabel('Y-values');
title('Plot of e^(x)');
end
end

Kindly revert for any queries

Thanks.


Related Solutions

Plot the function y = 10(1 = e-x/4) over the interval 0 ≤ x ≤ xmax, using a while loop to
Plot the function y = 10(1 = e-x/4) over the interval 0 ≤ x ≤ xmax, using a while loop to determine the value of xmax such that y(xmax) = 9.8.Properly label the plot. The variable y represents force in newtons, and the variable x represents time in seconds.
using series to solve differential equations using series to solve differential equations 1.) y’’-(e^5x)y’+xy=0,y(0)=2,y’(0)=1
using series to solve differential equations using series to solve differential equations 1.) y’’-(e^5x)y’+xy=0,y(0)=2,y’(0)=1
Solve the following differential equations: 1.) y"(x)+ y(x)=4e^x ; y(0)=0, y'(0)=0 2.) x"(t)+3x'(t)+2x(t)=4t^2 ; x(0)=0, x'(0)=0
Solve the following differential equations: 1.) y"(x)+ y(x)=4e^x ; y(0)=0, y'(0)=0 2.) x"(t)+3x'(t)+2x(t)=4t^2 ; x(0)=0, x'(0)=0
Using the range 0 ≤ x ≤ 1 and 0 ≤ t ≤ 1 make an...
Using the range 0 ≤ x ≤ 1 and 0 ≤ t ≤ 1 make an animated plot of: 1.) y1(x,t)=cos(4πt)sin(πx) 2.) y2(x,t)=cos(8πt)sin(2πx) using matlab
Solve the following differential equations: 1. x"(t)+ x(t)=6sin(2t) ; x(0)=3, x'(0)=1 2.y"(t)- y(t)=4cos(t) ; y(0)+0 ,...
Solve the following differential equations: 1. x"(t)+ x(t)=6sin(2t) ; x(0)=3, x'(0)=1 2.y"(t)- y(t)=4cos(t) ; y(0)+0 , y'(0)=1
Solve the IVP using Laplace transforms x' + y'=e^t -x''+3x' +y =0 x(0)=0, x'(0)=1, y(0)=0
Solve the IVP using Laplace transforms x' + y'=e^t -x''+3x' +y =0 x(0)=0, x'(0)=1, y(0)=0
1. Using the equations describing the standard atmosphere, plot the speed of sound (in m/s, ft/s...
1. Using the equations describing the standard atmosphere, plot the speed of sound (in m/s, ft/s and knots) in the altitude range sea level – 32 km. You can use Matlab or Excel (10 points). 2. An airfoil has a critical Mach number of ??? = 0.65. The wing is swept back at 30°. a) What is the design flight Mach number for this wing? (2 points) b) What is the design flight speed in knots at an altitude of...
Plot using RStudio Consider a binomial random variable, X. i. Plot the pmf of X ∼Bin(n...
Plot using RStudio Consider a binomial random variable, X. i. Plot the pmf of X ∼Bin(n = 10, p = 0.3). ii. Plot the pmf of X ∼Bin(n = 10, p = 0.7). iii. Plot the pmf of X ∼Bin(n = 100, p = 0.3). iv. What happens to the shape of the pmf of X ∼Bin(n, p) when p gets larger? v. What happens when n gets larger
Generate a sample of 1000 random floating numbers (from 0 to 1) using numpy. Then plot...
Generate a sample of 1000 random floating numbers (from 0 to 1) using numpy. Then plot it and compare with a normal distribution plot close to that region (from 0 to 1) as well. Hint: Using Seaborn module
Use matlab to plot Taylor approximation for f(x) for x near 0 Given f(x) = exp(x)...
Use matlab to plot Taylor approximation for f(x) for x near 0 Given f(x) = exp(x) Use subpots to plot and its absolute and realative erros for N= 1,2,3 PLease give matlab code for Taylor and explain in detail, Thank you
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT