|
EDA365欢迎您登录!
您需要 登录 才可以下载或查看,没有帐号?注册
x
我的代码解常微分一直说要返回列向量,有大神帮忙看看嘛4 Y- `3 v- Z. e; G6 R; [7 k, w
% ^3 f( M, o& [8 }% a& b E. ?这是代码:4 _- y" A" d+ X! n1 l4 i+ }4 n4 O
function s=mywork(t,y,eta1,eta2,G1,yieldstress,contactstrain,flow,arg)7 I: f% A: q& {$ T W& D( ~* J
switch flow4 S7 P8 [( @7 u! S
case 'creep & recovery'
( L/ ^0 B% O! o stress0=arg(1);
5 J# a% f! Z" s3 L! t! m risetime=arg(2);
% c8 n z* A( h' I0 B2 W2 X! x5 W creeptime=arg(3);5 P8 I6 E# T0 h' L* @: `# G+ r
if t<risetime
( A. A1 G: I$ H# B: [9 \ stressrate=stress0/risetime;8 o: l/ c& l4 f0 `9 `# }
stress=stressrate*t;+ _- M3 _# [: E: G) A0 ~
elseif t<creeptime3 ]2 O9 l5 o2 N6 M* ~6 |) E6 D
stressrate=0;
7 O+ j' g1 b7 l stress=stress0;
( ~8 K7 a$ Q0 @7 e/ r3 a# F5 x elseif t<creeptime+risetime
% V; N; J4 F2 i) z" J2 g stressrate=stress0/risetime;
! c3 X& @7 S' d' f* s' x! V stress=stress0-stressrate*(t-creeptime);0 [8 w0 b! _5 ?* q
else
5 b/ E+ G9 c( u& X stressrate=0;
( @" F; e5 F* ~3 M z stress=0;3 C: M: K% f( E' S) ]1 U9 _/ M6 w
end$ H3 ^% {0 ]* c5 ]* @! I8 I: I+ N
gam1=y(1);
& l. b* E! y" F- a gam2=y(2);8 P: ^% c2 p$ L+ D2 T: B
s(1)=gam2;
6 c% T A4 l! P/ N- n3 h 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);; B/ C& D' u/ m: p5 B; l
/ \; z- G, F: S2 T1 ~6 q# t5 D1 I( [& k6 x+ c8 o v
1 _3 D( p. P# ^, b8 Q' _clear all1 @5 t) `* }( p' I7 F) M$ V* m
clc
; e2 F) f( K+ X: i. Nwarning off
" `2 ?$ {+ H5 c+ d& ?. P/ Z9 y/ `
, z, i ~+ `9 G3 ]- O2 xeta1=10; % [Pa.s], l# G6 {$ |' o, ]: e& Z5 G
eta2=20; % Pa.s]2 \& e2 l1 G, o$ |6 \7 r" y
G1=2; % [Pa]( w& e' a+ K8 g0 {4 L0 L* p
G2=5; %[Pa]2 }$ ^5 W5 ]7 ]) ]- v
yieldstress=5; % [Pa]
: ?2 r1 |5 X( P7 ?3 p$ W0 scontactstrain=5;
4 h, L$ y' H; r6 }5 n, J8 Z! _9 e1 Y$ u& W& Y& x4 i" m
& B% r4 a& A. o$ j. P- V
flow='creep & recovery';
; m# s/ v) j& M& |# c5 x' dstress0=1:2:10;
5 q; ^: ]9 c7 l, K* J6 prisetime=0.01;' a: H. D" h J0 e( [
creeptime=100;; |( z/ k: F2 z4 z
for i=1:length(stress0)
) {6 j* R1 x1 l [t,strain]=ode15s(@mywork,[0 10],[0 0],[],eta1,eta2,G1,yieldstress,contactstrain,flow,[stress0(i) risetime creeptime]);1 @- f" d) g% S; }$ ]6 ]
subplot(2,3,3); semilogx(t,strain(:,1)); hold on* T9 E) C: Y. D# `8 j6 G& N, a* r9 h
a{i}=strcatnum2str(stress0(i),'(Pa)');% \$ l* Z$ j0 n8 Z; o% S& @
end
4 I+ |) Z3 U/ t" vxlin([1e-4 1000]);
( `5 _6 G5 f7 pxlabel('Time(s)'); ylabel('Shear strain(-)');
" Z& t( k' G' t7 u$ {' V7 f# Q' wlegend(a)
, w; E. F& x( S7 l' K
- l( }$ c+ u9 H7 r2 C
* Y' N2 m: R1 f: ?. I
3 x( S4 U" M! L错误使用 odearguments (第 93 行)2 O( \8 j7 m8 W6 D; K) q: ^! {/ |
MYWORK 必须返回列向量。
# g3 u0 H; c# x/ i- p# s+ L! E2 i5 O0 y3 ^
出错 ode15s (第 152 行)( P( E, p( L7 ]( ]
odearguments(FcnHandlesUsed, solver_name, ode, tspan, y0, options, varargin);
. }5 b& E$ Q, ^$ h1 \ B1 U) Z6 `3 q: o$ r
出错 Untitled2 (第 20 行)5 j2 }2 d1 s9 N( K+ P7 K
[t,strain]=ode15s(@mywork,[0 10],[1 0],[],eta1,eta2,G1,yieldstress,contactstrain,flow,[stress0(i) risetime creeptime]);) Y: e3 k& K' g8 c4 D
8 b3 X' c5 E9 w2 k* R* a
! a' L( ~' i- R感谢大神们!
^7 n5 z8 ^% r8 K! W- x0 \0 m9 W |
|