|
|
EDA365欢迎您登录!
您需要 登录 才可以下载或查看,没有帐号?注册
x
我的代码解常微分一直说要返回列向量,有大神帮忙看看嘛
4 H8 i+ N+ w$ W! x
& O6 T( ^& h, A( r$ Q$ `$ g: q/ K这是代码: M& C# c3 b0 d& Z$ |! s
function s=mywork(t,y,eta1,eta2,G1,yieldstress,contactstrain,flow,arg)3 |; ~( d- |! ?
switch flow
) d9 K% `! T, k- s: p9 v# G0 {case 'creep & recovery', u8 Z9 K6 a. i0 T
stress0=arg(1);
6 J. t2 K, h$ f' p risetime=arg(2);; y2 I+ U1 x* J6 `- i
creeptime=arg(3);1 l* u& y3 Q y
if t<risetime; r! W/ Z2 }# w7 ^/ p8 w
stressrate=stress0/risetime;/ W5 y) `4 N0 f8 f7 o- O
stress=stressrate*t;
P6 S; v. N, X, m6 ? elseif t<creeptime2 A7 O# v4 `9 \' V& ?2 l
stressrate=0;
8 p) ^; o( l6 R7 w; ^' K stress=stress0;6 G1 @% j$ b8 N8 m4 a. }: W0 s
elseif t<creeptime+risetime
# y* X g4 w$ t0 O' a4 |2 S8 _ stressrate=stress0/risetime;& h" o, y) \! }; Q) g! K5 o u
stress=stress0-stressrate*(t-creeptime);" t6 e) Z5 z5 I! Z
else
& L+ Z& a4 ?9 c stressrate=0;
. D/ {; i7 _" l stress=0;
$ e: v# U' @( v- i6 h- G end, a& e( P! A/ Z3 |) b, j
gam1=y(1);9 g3 C9 x& L o% b
gam2=y(2);- }: E6 e$ K( v1 m! d& U
s(1)=gam2;7 ?* c% [& b9 ?
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 U& q: t, ?- `4 {) X+ K, |0 ?' S+ ~/ I, f: O2 c
% d4 M8 @ H" a2 P# G2 S
6 a% p: \# Q+ K+ a
clear all
' M* U& N% |8 Q, @7 mclc5 ]" e6 ]+ A' ?4 k& J) ^ t
warning off
( a" [( n" W( Q3 |- }+ f* _2 P3 L7 V
eta1=10; % [Pa.s]
1 h0 ~$ z5 r; @4 e' ~eta2=20; % Pa.s]
6 L. N$ H- h5 X5 bG1=2; % [Pa]! o9 w# [1 j4 `2 z2 [ H6 \4 w9 B7 n# |
G2=5; %[Pa]0 N3 u5 R; T0 A( _$ G1 ~" Q
yieldstress=5; % [Pa]
" h' k0 n; U: r% Ncontactstrain=5;
2 L$ @; }8 J; v5 k7 I) A+ d) V. @. o8 i$ |% K
; m0 m- y8 {6 V, B# u R9 H
flow='creep & recovery';( U6 S0 l1 [; L; \
stress0=1:2:10;
% ?( }. _5 |# C" u( ?9 orisetime=0.01;
; X; A `% V% b+ f# [creeptime=100;6 i7 u* y, V- }8 X
for i=1:length(stress0)
, j7 J; S3 g# {4 \8 e [t,strain]=ode15s(@mywork,[0 10],[0 0],[],eta1,eta2,G1,yieldstress,contactstrain,flow,[stress0(i) risetime creeptime]);7 C. X& _' i/ n7 y6 t, h
subplot(2,3,3); semilogx(t,strain(:,1)); hold on1 x8 q5 _7 Z3 y' ^, g: w) k+ Z5 P
a{i}=strcatnum2str(stress0(i),'(Pa)');
9 V# G/ e4 V w4 f) Wend
4 N2 ~3 b, X! q' [/ M( c1 R- N5 uxlin([1e-4 1000]);
0 W# o: f, i1 s6 O) ~ j \4 `5 nxlabel('Time(s)'); ylabel('Shear strain(-)');& g" o. k% G1 p- Q; W
legend(a)
: L" F2 ~6 r9 U3 d' c7 {9 Q6 |5 y$ l. J
x$ M6 H: [3 z! N7 @7 \8 r5 \9 t& o1 I5 J# W% A
错误使用 odearguments (第 93 行)$ ]: @3 { T. p1 A- c1 v- {
MYWORK 必须返回列向量。
9 I& ]( x7 p3 f0 m- y6 H) [' \. _: d6 p+ J; O" {6 C1 {' R
出错 ode15s (第 152 行)
* `; i- u: e! r8 U odearguments(FcnHandlesUsed, solver_name, ode, tspan, y0, options, varargin);4 N8 T; U7 e& |, ?" F% U# F$ a
* j% E' Z' L" u X出错 Untitled2 (第 20 行)
/ K" a% u# Z( @& ?5 Y+ M [t,strain]=ode15s(@mywork,[0 10],[1 0],[],eta1,eta2,G1,yieldstress,contactstrain,flow,[stress0(i) risetime creeptime]);5 D# y/ K" B3 y2 b! o9 q% ]7 C/ m
1 b. K' J8 R% k
% H( v$ \) D' {3 G感谢大神们!
# }# c& k& |' V% E7 N9 t# W) k |
|