|
EDA365欢迎您登录!
您需要 登录 才可以下载或查看,没有帐号?注册
x
我的代码解常微分一直说要返回列向量,有大神帮忙看看嘛+ p. L! J( Y8 \* o
6 y2 Y9 A- _5 O% \3 k# H这是代码:1 z9 N, e/ j; u9 x! w: x
function s=mywork(t,y,eta1,eta2,G1,yieldstress,contactstrain,flow,arg)- m/ s$ i5 E! |3 p5 J% W
switch flow
P& Q+ W5 N/ I9 d! Z8 |! o% Ncase 'creep & recovery'
) ^0 Y7 ~& ?1 B% U# O+ h1 P stress0=arg(1);% K& w E$ _% N; B2 S" q# ]4 Z; v3 Z" h
risetime=arg(2);
/ m0 o( V R/ l: k- f3 v3 Z8 {0 g1 V! A creeptime=arg(3);' f& D+ d4 F/ @) c
if t<risetime" r0 Y2 b0 L8 a
stressrate=stress0/risetime;7 K1 u; R( c$ x& p) \4 E4 Y
stress=stressrate*t;$ W% @# G3 @' U/ G& [
elseif t<creeptime1 R' h+ _7 H7 N- n
stressrate=0;
, }6 ~! X) n/ U8 ? C. Y stress=stress0;0 ^2 G' B2 }# m- Y' i9 V
elseif t<creeptime+risetime
2 ?& a' ^9 q% l- j1 B3 R- s stressrate=stress0/risetime;3 p M' v' d$ [9 n! l
stress=stress0-stressrate*(t-creeptime);2 Q& L- N# x1 u& I4 E, G$ Y
else
4 I; f' F! Q( b' y9 B4 V% W stressrate=0;; {7 c. r: b" W: D1 ]! S+ A9 M
stress=0;
! K# i) W7 ?2 U+ C end
0 E4 O2 O7 ~7 A& p2 c- | gam1=y(1);
8 M4 h8 e1 `% ?3 e+ P6 A: E6 R gam2=y(2);1 o3 U; w0 k- `
s(1)=gam2;1 {' j7 B1 F1 n; c$ E
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);! f& O# w* _9 R- S; I/ s8 o4 V3 ?
( ~5 y% z7 A7 K n# m# Z
4 P; L9 R8 |; K2 ]2 S$ U; D: Q9 |6 t" o. a) b B7 j. C* Z2 @3 e
clear all
# d; _6 \5 ]; |( o% u9 U6 h$ X; _clc2 b) S f% ?" y- ~, ?$ [
warning off3 y/ S* q3 }& S) R {
1 Z- D$ u) y5 ^" ceta1=10; % [Pa.s]
! B7 M7 D0 e- v9 n# H& }1 oeta2=20; % Pa.s]- E, u% H* a/ G
G1=2; % [Pa]9 J1 `8 Y2 ?$ H- v& d& h+ w
G2=5; %[Pa]/ T/ i; f9 R* d9 |8 V! k
yieldstress=5; % [Pa]+ w! X7 n" v6 R% T- k' J
contactstrain=5;
3 z4 r# s2 m: t/ X% @
1 b$ B' u8 w6 P- A9 Q7 ^* q# G/ F6 j; z2 v- }
flow='creep & recovery';
& F' n, _% [6 {; fstress0=1:2:10;
# h# H6 _! i2 o1 r7 w& ?& h" jrisetime=0.01;% C- V0 M! _7 t: I8 ?! B; z, e: E7 V
creeptime=100;' N# [- G4 m9 A9 [% n
for i=1:length(stress0)
" m/ I+ E8 ^4 G/ g. O6 I* L9 { [t,strain]=ode15s(@mywork,[0 10],[0 0],[],eta1,eta2,G1,yieldstress,contactstrain,flow,[stress0(i) risetime creeptime]);
& v8 o1 g2 \% m0 F8 a( f( E5 u$ ?5 U subplot(2,3,3); semilogx(t,strain(:,1)); hold on
1 ?) _4 y- P* Z, Y; {/ e a{i}=strcatnum2str(stress0(i),'(Pa)');
4 F) E0 T& _: [+ G1 F! _8 B6 U! @* xend
; H! r; j ^$ I+ d; _xlin([1e-4 1000]); 9 s0 M3 _$ M6 L7 ], Z# x2 h+ Q d8 k+ ?
xlabel('Time(s)'); ylabel('Shear strain(-)');
9 }; K( c( f$ Z4 @5 }8 _legend(a)
( f- C1 U4 i' q7 j) ^* B( {1 g1 C; W, {; o7 p( e V* r
, q* n0 G+ t" N7 J* G3 B) ~. Y' \# f( Y% T1 b& z E
错误使用 odearguments (第 93 行)
, |1 l) K. g. ~# D; `9 [( bMYWORK 必须返回列向量。
, `0 w4 N4 J7 _4 {* X- O+ t3 o- p8 ^# y, Y6 Z: ?. u9 X
出错 ode15s (第 152 行)9 w; v) Z* C6 Y( x
odearguments(FcnHandlesUsed, solver_name, ode, tspan, y0, options, varargin);0 H2 Q! j; K; W f, Z% R. Y
$ k5 H$ X' U2 ~! t* A; p6 V出错 Untitled2 (第 20 行)7 ^) \" @- [$ L0 P
[t,strain]=ode15s(@mywork,[0 10],[1 0],[],eta1,eta2,G1,yieldstress,contactstrain,flow,[stress0(i) risetime creeptime]); p8 K' ^% I! G; @7 x
8 H5 |1 L0 A8 F1 N/ b& ?$ I
9 I" Y4 q7 ^) s: }感谢大神们!
* P* W, W- D1 c4 Q; y! l8 [# T |
|