|
|
EDA365欢迎您登录!
您需要 登录 才可以下载或查看,没有帐号?注册
x
我的代码解常微分一直说要返回列向量,有大神帮忙看看嘛
/ y/ g8 Q+ \& s' ~! R
6 d2 z$ F2 k# _ t2 a/ k) s这是代码:* }' S* H0 c: L& M2 y& N
function s=mywork(t,y,eta1,eta2,G1,yieldstress,contactstrain,flow,arg); q3 Y4 U; a0 A5 r
switch flow4 Q L! R" b1 F8 l4 f
case 'creep & recovery'
, k' W% ^! {0 m: B: d s# S( ? stress0=arg(1);& X- P2 E% W. C3 V! i2 S
risetime=arg(2);
* @/ `- F' x! p+ A; d/ Y3 e% X creeptime=arg(3);2 o, t+ U5 t% a% ?% ?# Q- T% y5 b
if t<risetime
- Q% D N$ U& ]$ q9 P stressrate=stress0/risetime;% J1 ?6 H& J/ Y# ^/ A
stress=stressrate*t;6 z p7 K$ G& g4 y( g5 W
elseif t<creeptime
0 D' A V8 R2 z stressrate=0;
" H4 Z2 Y) U I$ U stress=stress0;( B2 z, Y* P' d, j6 a' {/ H$ E0 _8 h a
elseif t<creeptime+risetime
3 b5 p2 L$ O3 ?9 `! [4 l+ J# z stressrate=stress0/risetime;9 {: Y! A" j& e* A t/ Z
stress=stress0-stressrate*(t-creeptime);9 _1 s4 V' X* e$ z2 p! o- T7 M
else
: w2 g' M/ i% T& t- O6 ^$ E# @ stressrate=0;- T+ H; B D6 b9 S1 @9 e, |
stress=0;$ y7 Z# x) l6 c) n; w4 C
end3 g9 B/ V* P9 K' O5 G! ?3 b5 F
gam1=y(1);
& D. J- b. M$ ?+ l2 \& b9 ]- p gam2=y(2);, Z! C: ]: \5 }- d, A6 K- C/ i
s(1)=gam2; V4 A& q" {& C, O5 h1 b6 q* L
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);
1 r! w+ p& d% p$ |
% U, o9 ~. _5 T( t# j6 D; ^2 d u" _3 f* T0 S4 S( H- p$ Q, Y
2 E+ g9 h$ x4 D; _$ oclear all
( z4 E! `# L$ C2 T% [1 Pclc/ y: Z/ w- n# {5 N
warning off
; y9 X9 H0 i1 z" @2 M) O- k
/ v/ e. Y# P1 O( |* ~8 Beta1=10; % [Pa.s]
+ X/ {. s1 k+ r) P4 d$ E' K3 feta2=20; % Pa.s]
- i% W" c6 `+ k- ^1 Q m5 SG1=2; % [Pa]
8 B2 s& |9 H: D" T( K+ nG2=5; %[Pa]0 F# Y, f9 E" `" _8 J5 X( c
yieldstress=5; % [Pa]
; n9 b: m5 K% I$ J' @* Zcontactstrain=5;( l! }3 L" C4 ?$ x5 X+ v$ f
6 q) V8 c6 u. d5 x" k# @
4 v$ w# t% U$ E6 t9 Jflow='creep & recovery';2 x) S. k0 W6 C" x4 [
stress0=1:2:10;
6 v; C9 C+ C+ xrisetime=0.01;. S, u! s3 h0 n- P
creeptime=100;4 X, n0 ^) s1 v. X7 A
for i=1:length(stress0)- x. \! O: |9 _. E& W
[t,strain]=ode15s(@mywork,[0 10],[0 0],[],eta1,eta2,G1,yieldstress,contactstrain,flow,[stress0(i) risetime creeptime]);
$ D& w, \! `5 ^- o+ m: I' l9 s! G subplot(2,3,3); semilogx(t,strain(:,1)); hold on$ s6 N4 a3 R& N7 t9 [
a{i}=strcatnum2str(stress0(i),'(Pa)');
* C$ L) L1 H+ K+ eend; M: E' K; w G0 v% E8 b q: i
xlin([1e-4 1000]); 6 v! H' i8 d7 S" d( l
xlabel('Time(s)'); ylabel('Shear strain(-)');, Q% f5 v4 K" q. i7 P1 m
legend(a)' r+ t' [! h. W6 o
# ]& f4 Q m0 O: r0 C% F
: ^) l6 p0 E0 o$ }
& l9 U8 Q2 t0 y/ u# r错误使用 odearguments (第 93 行)
4 v+ V4 I3 F8 u: B5 \MYWORK 必须返回列向量。$ i5 F0 D$ m& k7 n9 j$ P
3 r& b' o. H3 V/ g9 l- v6 Y出错 ode15s (第 152 行) M2 } E9 ^3 q% y8 D& W
odearguments(FcnHandlesUsed, solver_name, ode, tspan, y0, options, varargin);
( p$ _1 {/ {2 T1 _) U8 s: h* Z: O) ^) h1 j4 f" Q6 D l! V
出错 Untitled2 (第 20 行)( f7 z7 z6 a% t
[t,strain]=ode15s(@mywork,[0 10],[1 0],[],eta1,eta2,G1,yieldstress,contactstrain,flow,[stress0(i) risetime creeptime]);
; {9 e5 y3 K6 } w. a2 Y+ b+ H7 m+ b. N
; J# v* ?6 h+ @! d6 l; Y感谢大神们!
5 Y: l8 Z1 w) |( W+ D1 C |
|