step response of non linear model

조회 수: 4 (최근 30일)
kruthika u
kruthika u 2023년 12월 13일
이동: Sam Chak 2023년 12월 16일
pls tell me clearly with MATLAB code...i am not comfortable with simulink. how to get the step respone of non-linear ODE for 3*3 MIMO boiler systems. the following are the equations.. i want the step response of the output not for the states.
x1dot = (-0.0018*u2*x1^(9/8)) + (0.9*u1) - (0.15*u3);
x2dot = ((((0.73*u2)-0.16)*x1^(9/8)-x2))/10;
x3dot = ((141*u3)-((1.1*u2)-0.19)*x1)/85;
y1 = x1;
y2 = x2;
y3 = 0.05*((0.13073*x3) + (100*((1-(0.001538*x3))*((0.8*x1)-25.6))/(x3*(1.0394-0.00123404*x1))) +(((((0.854*u2) -0.147)*x1) + (45.59*u1) -(2.514*u3) -2.096)/9) -67.975);
  댓글 수: 1
kruthika u
kruthika u 2023년 12월 15일
Dear sir, i used ur same code..
%% Task 1: Call ode45 to solve the state-space to produce state responses
tspan = [0 1];
x0 = [108; 66.65; 428]; % <-- non-zero initial values
[t, x] = ode45(@kruthikaSSS, tspan, x0);
%% Task 2: Generate only the output vector y of the state-space system
for j = 1:numel(t)
[~, y(j,:)] = kruthikaSSS(t(j), x(j,:));
end
%% Task 3: Plot Output responses
subplot(311)
plot(t, y(:,1)), grid on, ylabel('y_{1}')
subplot(312)
plot(t, y(:,2)), grid on, ylabel('y_{2}')
subplot(313)
plot(t, y(:,3)), grid on, ylabel('y_{3}'), xlabel('t')
%% State-Space System
function [xdot, y] = kruthikaSSS(t, x)
% initialzation
xdot = zeros(3, 1);
y = zeros(3, 1);
% definitions
x1 = x(1);
x2 = x(2);
x3 = x(3);
% Input signals: step functions
u1 = (t >= 0)*1;
u2 = u1;
u3 = u2;
% ODEs
xdot(1) = (-0.0018*u2*x1^(9/8)) + (0.9*u1) - (0.15*u3);
xdot(2) = ((((0.73*u2)-0.16)*x1^(9/8)-x2))/10;
xdot(3) = ((141*u3)-((1.1*u2)-0.19)*x1)/85;
% Outputs
y(1) = x1;
y(2) = x2;
y(3) = 0.05*((0.13073*x3) + (100*((1-(0.001538*x3))*((0.8*x1)-25.6))/(x3*(1.0394-0.00123404*x1))) +(((((0.854*u2) -0.147)*x1) + (45.59*u1) -(2.514*u3) -2.096)/9) -67.975);
end
but i get ERROR as: Error using plot
Vectors must be the same length.
Error in nonzeroinitial (line 11)
plot(t, y(:,1)), grid on, ylabel('y_{1}')
can u pls help me with this?

댓글을 달려면 로그인하십시오.

채택된 답변

Sam Chak
Sam Chak 2023년 12월 13일
Alternatively, you can describe the ODEs and the Outputs in a nonlinear State-Space System:
In other words, you only need to create a single local function with two output arguments. This method can also be applied to linear State-Space Systems, allowing you to freely design the input vector :
%% Task 1: Call ode45 to solve the state-space to produce state responses
tspan = [0 1];
x0 = [0; 0; 0];
[t, x] = ode45(@kruthikaSSS, tspan, x0);
%% Task 2: Generate only the output vector y of the state-space system
for j = 1:numel(t)
[~, y(j,:)] = kruthikaSSS(t(j), x(j,:));
end
%% Task 3: Plot Output responses
subplot(311)
plot(t, y(:,1)), grid on, ylabel('y_{1}')
subplot(312)
plot(t, y(:,2)), grid on, ylabel('y_{2}')
subplot(313)
plot(t, y(:,3)), grid on, ylabel('y_{3}'), xlabel('t')
%% State-Space System
function [xdot, y] = kruthikaSSS(t, x)
% initialzation
xdot = zeros(3, 1);
y = zeros(3, 1);
% definitions
x1 = x(1);
x2 = x(2);
x3 = x(3);
% Input signals: step functions
u1 = (t >= 0)*1;
u2 = u1;
u3 = u2;
% ODEs
xdot(1) = (-0.0018*u2*x1^(9/8)) + (0.9*u1) - (0.15*u3);
xdot(2) = ((((0.73*u2)-0.16)*x1^(9/8)-x2))/10;
xdot(3) = ((141*u3)-((1.1*u2)-0.19)*x1)/85;
% Outputs
y(1) = x1;
y(2) = x2;
y(3) = 0.05*((0.13073*x3) + (100*((1-(0.001538*x3))*((0.8*x1)-25.6))/(x3*(1.0394-0.00123404*x1))) +(((((0.854*u2) -0.147)*x1) + (45.59*u1) -(2.514*u3) -2.096)/9) -67.975);
end
  댓글 수: 6
Sam Chak
Sam Chak 2023년 12월 15일
Have you managed to resolve the error message for non-zero initial values? The provided code can generate the time responses for the desired outputs with unit step inputs. Once the technical issue from the original question is resolved, please consider clicking 'Accept' ✔ on the best answer and voting 👍 for other relevant answers as contributions to alternative solutions.
Since you opened a new post yesterday, asking how to compare the outputs of linear and nonlinear models, I believe the answer would be more appropriate there. We can leave a link here so that interested users can refer to it in the future: Comparison of Linear and Nonlinear Model Outputs.
kruthika u
kruthika u 2023년 12월 15일
ok sir.. thank u so much for ur prompt response and time

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Sam Chak
Sam Chak 2023년 12월 13일
For general nonlinear ODEs, you can refer to some examples in the ode45 documentation. To plot the state-dependent outputs, the idea is to first call ode45() to solve the ODEs and obtain the time responses of the state vector (x). Then, pass the time and state vectors as input arguments to the defined Output function to generate the time responses of the output vector (y). Two local functions, namely kruthikaODE() and kruthikaOut(), should be included at the end of the MATLAB script.
%% Task 1: Call ode45 to produce the state responses
tspan = [0 1];
x0 = [0; 0; 0];
[t, x] = ode45(@kruthikaODE, tspan, x0);
%% Task 2: Generate output vector using the Output function
for j = 1:numel(t)
y(j,:) = kruthikaOut(t(j), x(j,:));
end
%% Task 3: Plot Output responses
subplot(311)
plot(t, y(:,1)), grid on, ylabel('y_{1}')
subplot(312)
plot(t, y(:,2)), grid on, ylabel('y_{2}')
subplot(313)
plot(t, y(:,3)), grid on, ylabel('y_{3}'), xlabel('t')
% Place local functions at the end of Main script (after the 3 tasks)
%% ODE function
function xdot = kruthikaODE(t, x)
% initialzation
xdot = zeros(3, 1);
% definitions
x1 = x(1);
x2 = x(2);
x3 = x(3);
% step functions
u1 = (t >= 0)*1;
u2 = u1;
u3 = u2;
% Original ODEs
xdot(1) = (-0.0018*u2*x1^(9/8)) + (0.9*u1) - (0.15*u3);
xdot(2) = ((((0.73*u2)-0.16)*x1^(9/8)-x2))/10;
xdot(3) = ((141*u3)-((1.1*u2)-0.19)*x1)/85;
end
%% Output function
function y = kruthikaOut(t, x)
% initialzation
y = zeros(3, 1);
% definitions
x1 = x(:,1);
x2 = x(:,2);
x3 = x(:,3);
% step functions
u1 = (t >= 0)*1;
u2 = u1;
u3 = u2;
% Outputs
y(1) = x1;
y(2) = x2;
y(3) = 0.05*((0.13073*x3) + (100*((1-(0.001538*x3))*((0.8*x1)-25.6))/(x3*(1.0394-0.00123404*x1))) +(((((0.854*u2) -0.147)*x1) + (45.59*u1) -(2.514*u3) -2.096)/9) -67.975);
end
  댓글 수: 1
kruthika u
kruthika u 2023년 12월 14일
이동: Sam Chak 2023년 12월 16일
ON-LINEAR MODEL EQUATIONS:
xdot1,xdot2,xdot = states derivatives; x1,x2,x3=states; u1,u2,u3=inputs; y1,y2,y3=outputs
xdot1= (-0.0018*u2*x1^(9/8))+(0.9*u1) -(0.15*u3);
xdot2=((((0.73*u2)-0.16)*x1^(9/8)-x2))/10;
xdot3= ((141*u3)-((1.1*u2)-0.19)*x1)/85;
y1= x1;
y2= x2;
y3= 0.05*((0.13073*x3) + (100*((1-(0.001538*x3))*((0.8*x1)- 25.6))/(x3*(1.0394-0.00123404*x1))) +(((((0.854*u2) -0.147)*x1) + (45.59*u1) -(2.514*u3) -2.096)/9) -67.975);
LINEAR STATE SPACE MODEL FROM THE NON LINEAR MODEL:
a = [-0.0025087 0 0
0.069424 -0.1 0
-0.0066941 0 0];
b= [ 0.9 -0.34904 -0.15
0 14.155 0
0 -1.3976 1.6588];
c=[1 0 0
0 1 0
0.0063465 0 0.004705];
d=[0 0 0
0 0 0
0.25328 0.5124 -0.013967];
I have attached the step response for linear model. i want the step response for non linear model and compare with the linear model for the initial conditions (x10=108;x20=66.65;x30=428)

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Passivity and Sector Bounds에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by