Question

In: Mechanical Engineering

y'=y-x^2 ; y(1)= -4 Write a MATLAB program that makes two plots of the solution to...

y'=y-x^2 ; y(1)= -4

Write a MATLAB program that makes two plots of the solution to the equation using the following values. Suggest you use nested loops instead of two different loops. Be sure to label your plots.

a. x0 = 1.0, step size h = .2, number of steps n = 20.

b. x0 = 1.0, step size h = .05, number of steps n = 80.

Solutions

Expert Solution

here I solved in Matlab and copy of script and graph attached here below.

I don't think that you need to use any loop so I solved it directly without using any loop and plotted both given condition separately as shown below.

Sorry for your any kind of inconvenience, or If you find any query or need further help just comment below I will guide you surely. Thank you.

********************************** Matlab Script ***************************************

clc
clear all
xspan = [1:0.2:5];
y1 = -4;
[x,y] = ode45(@(x,y) y-x^2, xspan, y1);
subplot(2,1,1);
plot(x,y,'pk')
xlabel('value of x')
ylabel('value of y(x)')
grid on

xspan = [1:0.05:5];
y1 = -4;
[x,y] = ode45(@(x,y) y-x^2, xspan, y1);
subplot(2,1,2);
plot(x,y,'.k')
xlabel('value of x')
ylabel('value of y(x)')
grid on

***************************************************************************************************

Screenshots


Related Solutions

write a MATLAB script that plots the two functions ( y=(2x^2)-(3x)-4 and y=4sin(2Pix) - 1 )...
write a MATLAB script that plots the two functions ( y=(2x^2)-(3x)-4 and y=4sin(2Pix) - 1 ) in the same figure for x in [-1,3]. Add a title, x-label, y-label, and legend. ( MATLAB code and graph with all descriptions.)
y'=y-x^2 ; y(1)= -4 My MATLAB program won't work. I am trying to get the main...
y'=y-x^2 ; y(1)= -4 My MATLAB program won't work. I am trying to get the main program to output a plot of the three equations (1 from the main program and two called in the function). The goal is to code a Euler method and a 2nd order Taylor numerical solution for a. x0= 1.0 , step size h= 0.2, # of steps n=20 b. x0= 1.0 , step size h=0.05 , # of steps n=80 ; write a separate...
dervive the Frobenius solution to 4(x^2)*y"(x)+(3x+1)y(x)=0
dervive the Frobenius solution to 4(x^2)*y"(x)+(3x+1)y(x)=0
1) Let y be the solution of the equation y ′ = 4(x^4)*sin(x^4) satisfying the condition...
1) Let y be the solution of the equation y ′ = 4(x^4)*sin(x^4) satisfying the condition y ( 0 ) = − 1. Find y ( pi^1/3 ). 2) Find the largest value of the parameter r for which the function y = e^(rx) is a solution of the equation y ″ − 14 y ′ + 28 y = 0. 3) Let y ′ = − 4x^2*e^(-x^4) and let y ( 0 ) = 1. Find ln ⁡ (...
use a matlab built-in function to numerically solve: dy/dx= -x^2+((x^3*e^-y)/4) for 1<=x<=5 with y(1)=1 plot the...
use a matlab built-in function to numerically solve: dy/dx= -x^2+((x^3*e^-y)/4) for 1<=x<=5 with y(1)=1 plot the solution
a) Let y be the solution of the equation  y ′ = (y/x)+1+(y^2/x^2) satisfying the condition  y (...
a) Let y be the solution of the equation  y ′ = (y/x)+1+(y^2/x^2) satisfying the condition  y ( 1 ) = 0. Find the value of the function  f ( x ) = (y ( x ))/x at  x = e^(pi/4) . b) Let y be the solution of the equation  y ′ = (y/x) − (y^2/x^2) satisfying the condition  y ( 1 ) = 1. Find the value of the function  f ( x ) = x/(y(x)) at  x = e  . c) Let y be the solution...
Assume there are two plots of vineyard land, X and Y. If X costs twice as...
Assume there are two plots of vineyard land, X and Y. If X costs twice as much as Y and rents and discount rates are the same for each plot, the price difference can only be causes by different growth rates. a) For both plots, provide an abstract equation for the growth rate g. Assume that plot Y’s price is NPV. b) Based on your answer to (a), and assuming that the price-to-rent ratio for plot Y equals 12 and...
x^2*y''+x*y'+(x^2-1)y=0 what is the solution by using Frobenius method
x^2*y''+x*y'+(x^2-1)y=0 what is the solution by using Frobenius method
Hyperbolas 4(y - 1)^2 - (x + 4)^2 - 36 =0 find the x- and y-...
Hyperbolas 4(y - 1)^2 - (x + 4)^2 - 36 =0 find the x- and y- intercepts. label on graph state the domain and range
y^ = 0.9 - 0.3x x: 2 5 1 4 y: 1 2 1    -4...
y^ = 0.9 - 0.3x x: 2 5 1 4 y: 1 2 1    -4 a. Compute the three sums of​ squares, SST,​ SSR, and​ SSE, using the defining formulas. SST SSR SSE b. Verify the regression​ identity, SST​ = SSR​ + SSE. Is this statement​ correct? c. Determine the value of r squared ​(Round to four decimal places.) d. Determine the percentage of variation in the observed values of the response variable that is explained by the regression....
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT