フィルターのクリア

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 Center および File ExchangeArray and Matrix Mathematics についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by