MATLAB %define the sequence of the program[A,B,U,Y,M]=define_matrix();[H,D,I,R1,C2,C1,R2,P,Cd,RO,Q0,X1,P0,G]=input_parameter();[X2,C,A1]=calculation_parameter(Q0,Cd,P,R2,D,RO,G);[M]=calculation_matrix(M,A,B,U,Y,I,R1,C2,C1,R2,P0,P,X2,X2,A1,Q0,H,C);gra

来源:学生作业帮助网 编辑:作业帮 时间:2024/05/01 09:09:10
MATLAB %define the sequence of the program[A,B,U,Y,M]=define_matrix();[H,D,I,R1,C2,C1,R2,P,Cd,RO,Q0,X1,P0,G]=input_parameter();[X2,C,A1]=calculation_parameter(Q0,Cd,P,R2,D,RO,G);[M]=calculation_matrix(M,A,B,U,Y,I,R1,C2,C1,R2,P0,P,X2,X2,A1,Q0,H,C);gra

MATLAB %define the sequence of the program[A,B,U,Y,M]=define_matrix();[H,D,I,R1,C2,C1,R2,P,Cd,RO,Q0,X1,P0,G]=input_parameter();[X2,C,A1]=calculation_parameter(Q0,Cd,P,R2,D,RO,G);[M]=calculation_matrix(M,A,B,U,Y,I,R1,C2,C1,R2,P0,P,X2,X2,A1,Q0,H,C);gra
MATLAB
%define the sequence of the program
[A,B,U,Y,M]=define_matrix();
[H,D,I,R1,C2,C1,R2,P,Cd,RO,Q0,X1,P0,G]=input_parameter();
[X2,C,A1]=calculation_parameter(Q0,Cd,P,R2,D,RO,G);
[M]=calculation_matrix(M,A,B,U,Y,I,R1,C2,C1,R2,P0,P,X2,X2,A1,Q0,H,C);
graph_plot(M);
function [A,B,U,Y,M]=define_matrix()
%A_state_matrix
A=zeros(3,3);
%B=input_matrix
B=zeros(3,2);
%U_input_vector
U=zeros(2,1);
%Y_state_matrix
Y=zeros(3,1);
%M_output_matrix
M=zeros(1000,4);
function [H,D,I,R1,C2,C1,R2,P,Cd,RO,Q0,X1,P0,G]=input_parameter()
%步长H(s),阀芯直径D(cm),惯性质量I(kg),阀孔阻尼R1(bar_s/cm3)
%弹簧柔度C2(cm/kg),管道液容C1(cm3/bar),泄油液阻R2(bar_s/cm3)
%设定压力P(bar),初始压力P0(bar),流量系数Cd,油液密度RO(kg/cm3)
%泵理论流量Q0(cm3/s),阀口遮盖量X1(cm),重力加速度G(cm/s2)
H=6e-5; D=1.2; I=6.3e-5; R1=0.4; R2=1.5; C2=0.02;
C1=0.08; P=30; Cd=0.7; RO=0.0009; Q0=460; X1=0.14; P0=6; G=981;
function [X2,C,A1]=calculation_parameter(Q0,Cd,P,R2,D,RO,G)
PI=3.1415926;
X2=(Q0-P/R2)/(Cd*PI*D*sqrt(2*G*P/RO));
C=-Cd*PI*D*sqrt(2*G/RO);
A1=PI*D*D/4;
function [M]=calculation_matrix(M,A,B,U,Y,I,R1,C2,C1,R2,P0,P,X1,
X2,A1,Q0;H,C)
T=0;
A(1,1)=-A1*A1*R1/I; A(1,2)=-1/C2; A(1,3)=A1/C1;
A(2,1)=1/I; A(3,1)=-A1/I; A(3,3)=-1/(R2*C1);
B(1,1)=-1; B(3,2)=1;
U(1)=P*A1-(X1+X2)/C2; U(2)=Q0;
Y(1)=0; Y(2)=0; Y(3)=P0*C1;
M(1,1)=0; M(1,2)=Y(1)/I; M(1,3)=Y(2); M(1,4)=P0;
for j=1:1000,
[Y,T]=R_T(A,B,U,Y,H,X1,C,C1,T);
M(j+1,1)=T; M(j+1,2)=Y(1)/I; M(j+1,3)=Y(2); M(j+1,4)=Y(3)/C1;
end
function [Y,T]=R_T(A,B,U,Y,H,X1,C,C1,T)
%constrain
if Y(2)

MATLAB %define the sequence of the program[A,B,U,Y,M]=define_matrix();[H,D,I,R1,C2,C1,R2,P,Cd,RO,Q0,X1,P0,G]=input_parameter();[X2,C,A1]=calculation_parameter(Q0,Cd,P,R2,D,RO,G);[M]=calculation_matrix(M,A,B,U,Y,I,R1,C2,C1,R2,P0,P,X2,X2,A1,Q0,H,C);gra
Error:File:untitled.m Line:8 Column:1
Function definitions are not permitted at the prompt or in scripts.
这个是提示说你写的函数文件要单独建立在一个函数文件中,而不能直接将函数放在脚本文件中.具体方法如下:
一、先建立主程序 main.m
%define the sequence of the program
[A,B,U,Y,M]=define_matrix();
[H,D,I,R1,C2,C1,R2,P,Cd,RO,Q0,X1,P0,G]=input_parameter();
[X2,C,A1]=calculation_parameter(Q0,Cd,P,R2,D,RO,G);
[M]=calculation_matrix(M,A,B,U,Y,I,R1,C2,C1,R2,P0,P,X2,X2,A1,Q0,H,C);
graph_plot(M);
二、建立函数文件1 define_matrix.m
function [A,B,U,Y,M]=define_matrix()
%A_state_matrix
A=zeros(3,3);
%B=input_matrix
B=zeros(3,2);
%U_input_vector
U=zeros(2,1);
%Y_state_matrix
Y=zeros(3,1);
%M_output_matrix
M=zeros(1000,4);
三、建立函数文件2 input_parameter.m
function [H,D,I,R1,C2,C1,R2,P,Cd,RO,Q0,X1,P0,G]=input_parameter()
%步长H(s),阀芯直径D(cm),惯性质量I(kg),阀孔阻尼R1(bar_s/cm3)
%弹簧柔度C2(cm/kg),管道液容C1(cm3/bar),泄油液阻R2(bar_s/cm3)
%设定压力P(bar),初始压力P0(bar),流量系数Cd,油液密度RO(kg/cm3)
%泵理论流量Q0(cm3/s),阀口遮盖量X1(cm),重力加速度G(cm/s2)
H=6e-5; D=1.2; I=6.3e-5; R1=0.4; R2=1.5; C2=0.02;
C1=0.08; P=30; Cd=0.7; RO=0.0009; Q0=460; X1=0.14; P0=6; G=981;
四、建立函数文件3 calculation_parameter.m
function [X2,C,A1]=calculation_parameter(Q0,Cd,P,R2,D,RO,G)
PI=3.1415926;
X2=(Q0-P/R2)/(Cd*PI*D*sqrt(2*G*P/RO));
C=-Cd*PI*D*sqrt(2*G/RO);
A1=PI*D*D/4;
五、建立函数文件4 calculation_matrix.m
function [M]=calculation_matrix(M,A,B,U,Y,I,R1,C2,C1,R2,P0,P,X1,
X2,A1,Q0;H,C)
T=0;
A(1,1)=-A1*A1*R1/I; A(1,2)=-1/C2; A(1,3)=A1/C1;
A(2,1)=1/I; A(3,1)=-A1/I; A(3,3)=-1/(R2*C1);
B(1,1)=-1; B(3,2)=1;
U(1)=P*A1-(X1+X2)/C2; U(2)=Q0;
Y(1)=0; Y(2)=0; Y(3)=P0*C1;
M(1,1)=0; M(1,2)=Y(1)/I; M(1,3)=Y(2); M(1,4)=P0;
for j=1:1000,
[Y,T]=R_T(A,B,U,Y,H,X1,C,C1,T);
M(j+1,1)=T; M(j+1,2)=Y(1)/I; M(j+1,3)=Y(2); M(j+1,4)=Y(3)/C1;
end
六、建立函数文件5 R_T.m
function [Y,T]=R_T(A,B,U,Y,H,X1,C,C1,T)
%constrain
if Y(2)

matlab loop (a) Define a function handle for the function f(x) = x2.(b) Define the variable S to equal zero.(c) Use a three-line for loop to add each of the following to S in the order given:f(10),f(9),...,f(2),f(1).Don’t display anything.(d) After #define s(x) 3 #define S(x) 3 The function define empty! matlab中的S-函数问题永磁无刷直流电机,对于S-函数的实现,使用C MEX S-函数执行#define S_FUNCTION_NAME chengxu#define S_FUNCTION_LEVEL 2#include "simstruc.h"#include "math.h"`static void mdlInitializeSizes(S 英语翻译Just as Greenwich serves to define the Prime Meridianon the Earth's surface,so the Vernal Equinox servesto define the zero right ascension line. Define the term contract catering'' define the term transport科学 that the physical things define #define define what is a student's association This ordinances supports the industry's effort as they define compost as a produt ...求翻译~This ordinances supports the industry's effort as they define compost as a produt in Austria and likely as a product in Germany. 谢谢~ How will you define the word BRIBERY? Define the dependent variableI need English answer matlab s=[] matlab s=[] 英语翻译“the way in which consumers define a product from it’s most important attributes; meaning the place that the product occupies in the client’s mind in regards to products from the competition”源自 市场营销原理Principles of During my cousin's stay here,the sofa will_______as a bed for a night or twA.define B.regard C.consider D.serve 英语翻译This ordinances supports the industry's effort as they define compost as a produt in Austria and likely as a product in Germany.请不要软件翻译!