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".
i have marketing project to finish and my product is wine cock latter decoration. and i...
i have marketing project to finish and my product is wine cock latter decoration. and i have few question to this product. 1. what does your product mean to that market. what is your value proposition. how will your customers perceive your product compare to your competition. what will be customer alternatives and what will be 4 p's of marketing (price,product,place, and promotion)
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
Hi I have a java code for my assignment and I have problem with one of...
Hi I have a java code for my assignment and I have problem with one of my methods(slice).the error is Exception in thread "main" java.lang.StackOverflowError Slice method spec: Method Name: slice Return Type: Tuple (with proper generics) Method Parameters: Start (inclusive) and stop (exclusive) indexes. Both of these parameters are "Integer" types (not "int" types). Like "get" above, indexes may be positive or negative. Indexes may be null. Description: Positive indexes work in the normal way Negative indexes are described...
I have a problem with the code for my project. I need the two clients to...
I have a problem with the code for my project. I need the two clients to be able to receive the messages but the code I have done only the server receives the messages. I need the clients to be able to communicate with each other directly not throught the server. The requirements of this "local chat" program must meet are: 1. The chat is performed between 2 clients and a server. 2. The server will first start up and...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT