필터 지우기
필터 지우기

How to change m-file functions to a block using level 2 m-file s-function

조회 수: 1 (최근 30일)
Muhmmed
Muhmmed 2013년 6월 20일
hi i have written the m-file for a system of 4 partial differential equations using pdepe. and i got the results from the m-file. the question is how to use this m-file that is consist of some functions in level 2 m-file s function simulink block???
  댓글 수: 1
Muhmmed
Muhmmed 2013년 6월 20일
the m file is:
function [c,f,s] = pdex4pde(x,t,u,DuDx)
Te=393.15;
k1 = -12677.76*exp(-(24.21/(8.314*10^(-3)*Te))); k2 =219.5; k3 = 50390.52; k4 =-0.55; k5 = - 44684.159; k6 = 50390.52; k7 =0.0001444; k8 =22.6 *10^(5); k9=372*exp(-(24.21/(8.314*10^(-3)*Te))); k10=0.0526; k11=2.2502;
Q = 0.6003*10^(-8)*(Te^4-u(4)^4);
c = [1; 1; 1; 1; 1];
f = [(k1*k4*u(5))* DuDx; (k1*k2*u(5)-k3*u(2))* DuDx; -(k6*u(3))* DuDx; (-k7/(1+u(1))*k1*k8*u(5))* DuDx; k9*DuDx(5)* DuDx]; hg=205200; % 60
F=(u(3)-u(4));
s = [0; 0; k5*F; (k7/(1+u(2)))*(hg*F+Q); 0];
function u0 = pdex4ic(x)
u0 = [0.5; 8.52; 313.15; 303.15; 1];
function [pl,ql,pr,qr] = pdex4bc(xl,ul,xr,ur,t)
pl = [ul(1); ul(2); ul(3); ul(4); ul(5)]; ql = [1; 0; 1; 0; 1]; pr = [ur(1); ur(2); ur(3); ur(4); ur(5)]; qr = [0; 0; 0; 0; 0];
function pdex4 clc clear
m1=0;
ux0=8.52;
uy0=0.5;
utg0=300;
uts0=298;
uw0 = 0.1;
x = linspace(0,10,20); t = linspace(0,30,20);
sol = pdepe(m1,@pdex4pde,@pdex4ic,@pdex4bc,x,t);
u1 = sol(:,:,1); u2 = sol(:,:,2); u3 = sol(:,:,3); u4 = sol(:,:,4); u5 = sol(:,:,5);
x0=5;
X=sol(:,x0,2); Y=sol(:,x0,1); Tg=utg0+(utg0-sol(:,x0,3)); Ts=uts0+(uts0-sol(:,x0,4)); W=sol(:,x0,5);
figure plot(t,X,'--k', 'LineWidth', 1); set(gca,'FontSize',12) title('\bf X(1,t)'); xlabel('\bf Time t');
figure
hold on
plot(t,Y,'--r', 'LineWidth', 1);
set(gca,'FontSize',12)
title('\bf Y(1,t)');
xlabel('\bf Time t');
figure
plot(t,Tg,'--g', 'LineWidth', 1);
set(gca,'FontSize',12)
title('\bf Tg(1,t)');
xlabel('\bf Time t');
figure
plot(t,Ts,'--k', 'LineWidth', 1);
set(gca,'FontSize',12)
title('\bf Ts(1,t)');
xlabel('\bf Time t');
figure plot(t,W,'--k', 'LineWidth', 1); set(gca,'FontSize',12) title('\bf W(1,t)'); xlabel('\bf Time t');

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

답변 (0개)

카테고리

Help CenterFile Exchange에서 General Applications에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by