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

Please finish this code and make it work. This is my homework and my professor wont...
Please finish this code and make it work. This is my homework and my professor wont allow me to change the code in main, it's a set of huge numbers need to sort by radixsort with bit operation. #include <iostream> using namespace std; void radixLSD_help(int *items, int length, int bit) {    // – Count number of items for each bucket.    // – Figure out where each bucket should be stored (positions // of the first and last element...
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".
In Python I have a code: here's my problem, and below it is my code. Below...
In Python I have a code: here's my problem, and below it is my code. Below that is the error I received. Please assist. Complete the swapCaps() function to change all lowercase letters in string to uppercase letters and all uppercase letters to lowercase letters. Anything else remains the same. Examples: swapCaps( 'Hope you are all enjoying October' ) returns 'hOPE YOU ARE ALL ENJOYING oCTOBER' swapCaps( 'i hope my caps lock does not get stuck on' ) returns 'I...
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 =...
I have a programming project due tonight that I have already done once but my professor...
I have a programming project due tonight that I have already done once but my professor sent back because he said I did it wrong. He wants the following using linked lists but i only know how to do it with Arrays. Please try to explain your answer to me and not just give it to me. For this assignment you must write a program that implements a stack of integers. The stack should be implemented using classes and must...
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:...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT