Question

In: Advanced Math

I have to finish the code given by my diff eq professor to analyze the lorenz...

I have to finish the code given by my diff eq professor to analyze the lorenz function at different initial conditions and different values for p. I am not sure how to input the lorenz function in the way the code is set up.

Here is the code provided for matlab:

function lorenz

s = 10;
b = 8/3;
p = 0.15;

y = @(t,x) [ ; ; ]; % you are responsible for entering the lorenz system here

T = [0 200]; % sets the time interval; no need to edit
x0 = [1 1 1]; % initial conditions; this can and should be editied

[t,x] = ode45(y,T,x0); % ode solver; do not edit

plot3(x(:,1),x(:,2),x(:,3),'r') % plots 3d solution for entered conditions

grid on

Solutions

Expert Solution


%%Matlab code for Lorenz equation solution
clear all
close all

%value for alpha beta and eta
s=10; p=0.15; b=(8/3);
%and initial condition of y
y10=1; y20=1; y30=1;
%initial value for t
t0=0;
%t end values
tend=200;

y0=[y10;y20;y30];
%minimum and maximum time span
        tspan=[t0 tend];
        %Solution of ODEs using ode45 matlab function
        sol= ode45(@(t,y) odefcn1(t,y,s,p,b), tspan, y0);
        t1 = linspace(tspan(1),tspan(end),100001);
        %yy is the corresponding x y v and z
        yy1 = deval(sol,t1);
figure(1)     
plot3(yy1(1,:),yy1(2,:),yy1(3,:))
xlabel('y1');ylabel('y2');zlabel('y3')
title('3d line plot for Lorenz attractor initial cond [1 1 1] and p=0.15')

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%value for alpha beta and eta
s=10; p=10; b=(8/3);
%and initial condition of y
y10=1; y20=1; y30=1;
%initial value for t
t0=0;
%t end values
tend=200;

y0=[y10;y20;y30];
%minimum and maximum time span
        tspan=[t0 tend];
        %Solution of ODEs using ode45 matlab function
        sol= ode45(@(t,y) odefcn1(t,y,s,p,b), tspan, y0);
        t1 = linspace(tspan(1),tspan(end),100001);
        %yy is the corresponding x y v and z
        yy1 = deval(sol,t1);
figure(2)     
plot3(yy1(1,:),yy1(2,:),yy1(3,:))
xlabel('y1');ylabel('y2');zlabel('y3')
title('3d line plot for Lorenz attractor initial cond [1 1 1] and p=10')

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%value for alpha beta and eta
s=10; p=20; b=(8/3);
%and initial condition of y
y10=1; y20=2; y30=1;
%initial value for t
t0=0;
%t end values
tend=200;

y0=[y10;y20;y30];
%minimum and maximum time span
        tspan=[t0 tend];
        %Solution of ODEs using ode45 matlab function
        sol= ode45(@(t,y) odefcn1(t,y,s,p,b), tspan, y0);
        t1 = linspace(tspan(1),tspan(end),100001);
        %yy is the corresponding x y v and z
        yy1 = deval(sol,t1);
figure(3)     
plot3(yy1(1,:),yy1(2,:),yy1(3,:))
xlabel('y1');ylabel('y2');zlabel('y3')
title('3d line plot for Lorenz attractor initial cond [1 2 1] and p=20')

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%value for alpha beta and eta
s=10; p=20; b=(8/3);
%and initial condition of y
y10=1; y20=5; y30=1;
%initial value for t
t0=0;
%t end values
tend=200;

y0=[y10;y20;y30];
%minimum and maximum time span
        tspan=[t0 tend];
        %Solution of ODEs using ode45 matlab function
        sol= ode45(@(t,y) odefcn1(t,y,s,p,b), tspan, y0);
        t1 = linspace(tspan(1),tspan(end),100001);
        %yy is the corresponding x y v and z
        yy1 = deval(sol,t1);
figure(4)     
plot3(yy1(1,:),yy1(2,:),yy1(3,:))
xlabel('y1');ylabel('y2');zlabel('y3')
title('3d line plot for Lorenz attractor initial cond [1 5 1] and p=20')

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%value for alpha beta and eta
s=10; p=28; b=(8/3);
%and initial condition of y
y10=1; y20=1; y30=1;
%initial value for t
t0=0;
%t end values
tend=200;

y0=[y10;y20;y30];
%minimum and maximum time span
        tspan=[t0 tend];
        %Solution of ODEs using ode45 matlab function
        sol= ode45(@(t,y) odefcn1(t,y,s,p,b), tspan, y0);
        t1 = linspace(tspan(1),tspan(end),100001);
        %yy is the corresponding x y v and z
        yy1 = deval(sol,t1);
figure(5)     
plot3(yy1(1,:),yy1(2,:),yy1(3,:))
xlabel('y1');ylabel('y2');zlabel('y3')
title('3d line plot for Lorenz attractor initial cond [1 1 1] and p=28')

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%value for alpha beta and eta
s=10; p=28; b=(8/3);
%and initial condition of y
y10=1; y20=5; y30=1;
%initial value for t
t0=0;
%t end values
tend=200;

y0=[y10;y20;y30];
%minimum and maximum time span
        tspan=[t0 tend];
        %Solution of ODEs using ode45 matlab function
        sol= ode45(@(t,y) odefcn1(t,y,s,p,b), tspan, y0);
        t1 = linspace(tspan(1),tspan(end),100001);
        %yy is the corresponding x y v and z
        yy1 = deval(sol,t1);
figure(6)     
plot3(yy1(1,:),yy1(2,:),yy1(3,:))
xlabel('y1');ylabel('y2');zlabel('y3')
title('3d line plot for Lorenz attractor initial cond [1 5 1] and p=28')


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Function for evaluating the ODE
function dydt = odefcn1(t,y,s,p,b)

    eq1 = s*(y(2)-y(1));
    eq2 = y(1)*(p-y(3))-y(2);
    eq3 = y(1)*y(2)-b*y(3);

    %Evaluate the ODE for our present problem
    dydt = [eq1;eq2;eq3];
end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


Related Solutions

I already finish the argumentative topic about abortion, but my professor does not want me to...
I already finish the argumentative topic about abortion, but my professor does not want me to write about it. Can someone help me write 500 words about this argumentation "Education should be free for everyone".
This is the code I have. My problem is my output includes ", 0" at the...
This is the code I have. My problem is my output includes ", 0" at the end and I want to exclude that. // File: main.cpp /*---------- BEGIN - DO NOT EDIT CODE ----------*/ #include <iostream> #include <fstream> #include <sstream> #include <iomanip> using namespace std; using index_t = int; using num_count_t = int; using isConnected_t = bool; using sum_t = int; const int MAX_SIZE = 100; // Global variable to be used to count the recursive calls. int recursiveCount =...
this is my matlab code for class, my professor commented "why is the eps an input...
this is my matlab code for class, my professor commented "why is the eps an input when it is set inside the function and not specified as a variable? how do i fix? function[] = () %Declare Global Variables global KS; global KC; KC = 0; KS = 0; End = 0; while (End == 0) choice = questdlg('Choose a function', ... 'Fuction Menu', ... 'A','B','B'); switch choice; case 'A' Program = 'Start'; while strcmp(Program,'Start'); Choice = menu('Enter the Trigonometric...
* Show the output of the following BASH code: i=7 i=$((i-5)) if [ $i -eq 4...
* Show the output of the following BASH code: i=7 i=$((i-5)) if [ $i -eq 4 ] # -eq is == then         echo "Four" elif [ $i -eq 2 ] then         echo "Two" else         echo $i fi
I have a project to make and my professor wants me to make a Synopsis. She...
I have a project to make and my professor wants me to make a Synopsis. She wants me to put together a synopsis of the SBA grant EIDL loan program and payroll protection program. The criteria that the small businesses have to meet, what potential benefit would these small businesses receive and so on and so forth. What is the best format for this Synopsis? Thank you.
in java: In my code at have my last two methods that I cannot exactly figure...
in java: In my code at have my last two methods that I cannot exactly figure out how to execute. I have too convert a Roman number to its decimal form for the case 3 switch. The two methods I cannot figure out are the public static int valueOf(int numeral) and public static int convertRomanNumber(int total, int length, String numeral). This is what my code looks like so far: public static void main(String[] args) { // TODO Auto-generated method stub...
The code following is what I have so far. It does not meet my requirements. My...
The code following is what I have so far. It does not meet my requirements. My problem is that while this program runs, it doesn't let the user execute the functions of addBook, isInList or compareLists to add, check, or compare. Please assist in correcting this issue. Thank you! Write a C++ program to implement a singly linked list of books. The book details should include the following: title, author, and ISBN. The program should include the following functions: addBook:...
I'm getting an error with my code on my EvenDemo class. I am supposed to have...
I'm getting an error with my code on my EvenDemo class. I am supposed to have two classes, Event and Event Demo. Below is my code.  What is a better way for me to write this? //******************************************************** // Event Class code //******************************************************** package java1; import java.util.Scanner; public class Event {    public final static double lowerPricePerGuest = 32.00;    public final static double higherPricePerGuest = 35.00;    public final static int cutOffValue = 50;    public boolean largeEvent;    private String...
I have an error on my code. the compiler says 'setLastName' was not declared in this...
I have an error on my code. the compiler says 'setLastName' was not declared in this scope. this is my code : #include <iostream> using std::cout; using std::cin; using std::endl; #include <string> using std::string; class Employee {    public :               Employee(string fname, string lname, int salary)        {            setFirstName(fname);            setLastName(lname);            setMonthlySalary(salary);        }               void setFirstName(string fname)        {       ...
I have an unexpected indent with my python code. please find out whats wrong with my...
I have an unexpected indent with my python code. please find out whats wrong with my code and run it to show that it works here is the code : def main(): lis = inputData() customerType = convertAcct2String(lis[0]) bushCost = getBushCost(lis[0],int(lis[1],10)) flowerCost = getFlowerBedCost(int(lis[2],10),int(lis[3],10)) fertiCost = getFertilCost(int(lis[4],10)) totalCost = calculateBill(bushCost,fertiCost,flowerCost) printReciept(customerType,totalCost,bushCost,fertiCost,flowerCost) def inputData(): account, number_of_bushes,flower_bed_length,flower_bed_width,lawn_square_footage = input("Please enter values").split() return [account, number_of_bushes,flower_bed_length,flower_bed_width,lawn_square_footage] def convertAcct2String(accountType): if accountType== "P": return "Preferred" elif accountType == "R": return "Regular" elif accountType == "N": return...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT