|
EDA365欢迎您登录!
您需要 登录 才可以下载或查看,没有帐号?注册
x
我的代码解常微分一直说要返回列向量,有大神帮忙看看嘛+ D+ F! s% `: N* J- Y; C
! u8 w4 ^/ _, f; h. B# L- S这是代码:" U' u) ?; q' E
function s=mywork(t,y,eta1,eta2,G1,yieldstress,contactstrain,flow,arg)0 u- `) l6 d! \ z* U7 }! J+ a
switch flow1 Z( h9 X$ ^$ I+ x* R3 f O' F- g
case 'creep & recovery'5 X5 A" S/ m' ~0 Z# F5 h3 o
stress0=arg(1);
: z3 W' W) R/ Y, V! b6 r( v risetime=arg(2); E2 ~0 ]+ W0 o( m+ M
creeptime=arg(3);9 B) m0 j, }7 o, k
if t<risetime
8 c4 _7 `- w) s3 \ u stressrate=stress0/risetime;
3 j+ H5 b* p& \) b stress=stressrate*t;$ f7 k4 ~- N! ]' F$ q: _5 `6 z, f
elseif t<creeptime
1 }' Z, h; a& A& ]) q$ n stressrate=0;% p3 P9 W( R8 w: a4 m0 {* y
stress=stress0;' c2 V6 s% D' q5 z" O& g8 J
elseif t<creeptime+risetime1 I* D# V: [5 W7 a6 r
stressrate=stress0/risetime;+ s, O; w( T4 M
stress=stress0-stressrate*(t-creeptime);
. |; w# i- _; R Z4 c- ^; m else& c- m# s4 b$ Q5 K8 H
stressrate=0;
3 |5 H3 x- V) ~9 X- o( F6 S stress=0;
# k9 f7 \/ m* {& w0 `4 z end
+ _# g* b+ P/ a o* H m gam1=y(1);
$ g- ~. f. k/ r. B. K5 |+ ?( R$ B gam2=y(2);2 _3 n. I+ E, X# h8 ~ y% W$ E
s(1)=gam2;. t' V% d2 A% K7 P( M; m
s(2)=G1/(eta1*eta2*((abs(gam1)-contactstrain)>0))*((stress-eta2*gam2*((abs(gam1)-contactstrain)>0)-sign(stress-eta2*gam2*((abs(gam1)-contactstrain)>0))*yieldstress)*((abs(stress-eta2*gam2*((abs(gam1)-contactstrain)>0))-yieldstress)>0)-eta1*gam2+eta1/G1*stressrate);" X( z7 h6 ?/ |4 x- S, }; y
}, g& o! R/ A. E7 ?1 q1 l8 m! R# C$ g# X N
" K) s W0 ^ L4 u" g' t* U. Rclear all0 q+ D9 i$ ^2 `& F1 w
clc4 B2 j( P( h$ a. W) k, t+ }- E. v/ v
warning off
) H: Y5 S0 p/ j+ J
6 l+ j& m% F0 u8 y1 ueta1=10; % [Pa.s]
z) q8 T" U5 Q' E, U2 v6 veta2=20; % Pa.s]
! c( G: _% z) q' @* E) QG1=2; % [Pa]
+ R2 O! X* X( D6 {$ oG2=5; %[Pa]
( F8 q9 A0 q4 s" v; ]yieldstress=5; % [Pa]
) J" x/ h: M) a' ?: ?contactstrain=5;2 e# ?8 U8 C" S; m ]
+ H2 a5 _" y- K5 v, w# j" D w8 I
3 I7 A$ r2 O9 Q) G+ D sflow='creep & recovery';
* t4 W9 T" W/ m9 J5 O& ustress0=1:2:10;; [7 o: {1 h2 v' E* x. m
risetime=0.01;( Z h: o# D% B$ A/ X
creeptime=100;
?: }( r8 V, Z: K) s6 mfor i=1:length(stress0)3 p. k8 `0 b7 {- W
[t,strain]=ode15s(@mywork,[0 10],[0 0],[],eta1,eta2,G1,yieldstress,contactstrain,flow,[stress0(i) risetime creeptime]);0 T4 J5 I8 a h7 k' r; p: G3 V2 n- a
subplot(2,3,3); semilogx(t,strain(:,1)); hold on
5 J$ ?! l2 O3 j a{i}=strcatnum2str(stress0(i),'(Pa)');
# a, M2 o& m$ R* _0 @; a$ Aend
/ [& l: c* T9 G/ V( p/ Qxlin([1e-4 1000]);
* E! K- J. K8 I& J' _6 I7 z4 G* Pxlabel('Time(s)'); ylabel('Shear strain(-)');
% {! }: @4 A9 z8 q" V; P+ rlegend(a)$ j4 E4 d) J5 j8 W8 d
+ A/ I9 g, f' e. h8 d" \
: `- ~- n( C6 Q6 I7 [, M- l& `4 F
6 I% V* r4 k- k: q# | o错误使用 odearguments (第 93 行)
! i9 ?; n9 B: n( l7 n5 Q1 [MYWORK 必须返回列向量。( ~7 [3 I5 z; n) J; t. [
1 v* @ l% D* z9 o$ i. e出错 ode15s (第 152 行): L9 _$ y8 h8 Q% A- e" q
odearguments(FcnHandlesUsed, solver_name, ode, tspan, y0, options, varargin);* `, f! B6 N7 w) N- Y& _- _) k
0 J' g; t4 v. u7 x: I& F7 S
出错 Untitled2 (第 20 行)
, D0 |+ R# X% e8 e* u [t,strain]=ode15s(@mywork,[0 10],[1 0],[],eta1,eta2,G1,yieldstress,contactstrain,flow,[stress0(i) risetime creeptime]);
7 K& T& J I6 s
. e6 G* M- p9 l. [
$ n4 D/ d8 Y8 i4 C& _( j+ D# _感谢大神们!
- ^( I+ X0 r+ l1 ~* m, v, d |
|