|
|
EDA365欢迎您登录!
您需要 登录 才可以下载或查看,没有帐号?注册
x
我的代码解常微分一直说要返回列向量,有大神帮忙看看嘛
( S2 F+ ]7 q4 [ r0 |: F! V/ v8 G. @5 I1 v+ m
这是代码:
- I8 s$ i9 y# u2 m3 Dfunction s=mywork(t,y,eta1,eta2,G1,yieldstress,contactstrain,flow,arg)* e. T# d. s' G: C" T* k( X# W
switch flow8 i' A2 i$ T8 g) h
case 'creep & recovery'
0 e y# l; D6 R8 q. a0 Z. T( N% P1 v stress0=arg(1);
9 b! \: A3 s. y2 x3 U risetime=arg(2);
# n" h. f9 h6 B7 s( N; g% M& u creeptime=arg(3);
( N9 O1 B( k& `4 b5 j# H- m if t<risetime% ] `8 I+ f; A; J* y- Y
stressrate=stress0/risetime;) {, V; I) I t$ d7 b3 e
stress=stressrate*t;2 I1 ~- n" f0 W. a, a2 X
elseif t<creeptime
, n# _# T3 f$ \8 n stressrate=0;" E8 N) ]& S% W' p4 ~5 k2 [* d9 ~) z
stress=stress0;
# ]% s6 T2 e- N% y elseif t<creeptime+risetime5 R6 m' K9 ~, T6 Y. h. [# A* ~
stressrate=stress0/risetime;( _- L3 D5 V; B- c& k- A
stress=stress0-stressrate*(t-creeptime);0 \! w- B, g$ ~* S8 H& i8 b+ n2 V- l
else! P3 w' R! {" V* r7 A+ V
stressrate=0;
$ R% I! y4 k8 g$ B+ b. B4 i stress=0;9 C3 w. ?# {* v* _$ G: A
end6 j/ |1 q w3 W, u
gam1=y(1);8 ^ z4 M8 l! t
gam2=y(2);! Y Q/ w' ?9 r2 `. J, g4 r% v
s(1)=gam2;; G2 O/ H7 K2 ~* w# a* {3 u
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);- y0 } N& `+ V5 M
( T O) {2 v3 N3 O5 Q3 q+ E! q; u& L# e2 ?/ v! i
5 p% M; l/ k" X9 r) `clear all2 X0 a+ t, \9 g& {
clc& f2 J! t! h7 ^. T1 u9 [
warning off K# A# E Y/ |/ M/ l
; j7 Q/ b: ^, x0 v5 |eta1=10; % [Pa.s]
/ E( Z: z# y0 |! ^3 [* U4 q; ueta2=20; % Pa.s]
3 \! G. g. s9 uG1=2; % [Pa]0 U1 \9 O3 J2 P" ^' |
G2=5; %[Pa]
$ d# o% ~$ g; E7 v6 ]* Zyieldstress=5; % [Pa]
z+ U1 o" }: F7 w. Z* ^2 Fcontactstrain=5;
4 n( e/ U6 z; A2 t2 I* T" T, C9 |" E. U" l5 U- o
- z1 S9 _" X7 i! U4 f
flow='creep & recovery';
1 Z5 w& S# z; `stress0=1:2:10;& o, y/ ?' B7 u6 Z& s0 c7 |9 s
risetime=0.01;$ l& _6 o0 Y& c' i7 }
creeptime=100;
7 [* z' P3 ]( h, h/ B' p# Gfor i=1:length(stress0). {* h7 H$ C# @' h. m
[t,strain]=ode15s(@mywork,[0 10],[0 0],[],eta1,eta2,G1,yieldstress,contactstrain,flow,[stress0(i) risetime creeptime]);
: G9 p( x9 Z7 q9 b" G# H) T subplot(2,3,3); semilogx(t,strain(:,1)); hold on% O* W; O' v! B/ U4 w
a{i}=strcatnum2str(stress0(i),'(Pa)');
( a1 {6 R9 b; V# d4 n$ A! W9 q0 Tend
/ A! Y$ [% U" }xlin([1e-4 1000]); 8 j# E5 s' _' w' C! z9 A% K
xlabel('Time(s)'); ylabel('Shear strain(-)');
6 M# O% s9 T! i$ Flegend(a)
, k. r- {( d( l' a! d
+ \% E4 Q8 ^% q7 M
# @: I$ m$ V7 W, A* }$ G6 t0 S9 R5 c9 n( L0 l/ v) j) W4 n7 ^
错误使用 odearguments (第 93 行)8 p; P+ `8 @4 S' B
MYWORK 必须返回列向量。+ C7 C! L6 A* ^3 W
$ t/ ]% k$ ^6 f( V. }( w2 w出错 ode15s (第 152 行)* g# [; }) D& i8 d$ V
odearguments(FcnHandlesUsed, solver_name, ode, tspan, y0, options, varargin);+ v9 ]+ @& ]* n" M+ V/ L
( W3 |# l8 {* b) O& o& c- N出错 Untitled2 (第 20 行)* h2 v/ W C: r/ O
[t,strain]=ode15s(@mywork,[0 10],[1 0],[],eta1,eta2,G1,yieldstress,contactstrain,flow,[stress0(i) risetime creeptime]);
8 f1 ~: p$ s: K& E- [! j. a1 o
) D, O) K' F# o P" s! V+ F% [' I* z$ x! {, S
感谢大神们!
, g9 y0 W0 i7 _- |" D |
|