24小时热门版块排行榜    

Znn3bq.jpeg
查看: 1494  |  回复: 7
当前只显示满足指定条件的回帖,点击这里查看本话题的所有回帖

wzycrfpxz

新虫 (初入文坛)

[求助] matlab 问题求助,一段程序出错,求纠错

function dx=lunar(t,x,u)
syms t x u;
u0=45760.00;
if ((x(6)/x(5))*cos(atan(x(7)/x(6)))+(x(7)/x(5))*sin(atan(x(7)/x(6)))-(3.283e-4)*x(10))+1>0
    u=u0;

else   u=0.00;
dx=[(u/x(5))*cos(atan(x(7)/x(6)));
    (u/x(5))*sin(atan(x(7)/x(6)));
    x(1);
    x(2);
    (-3.281e-4)*u;
    0;
    -x(9);
    0;
    0;
    (u/x(5)^2)*cos(atan(x(7)/x(6)))*x(6)+(u/x(5)^2)*sin(atan(x(7)/x(6)))*x(7)];

end

??? Error using ==> mupadmex
Error in MuPAD command: Index exceeds matrix dimensions.

Error in ==> sym.sym>sym.subsref at 1366
            B = mupadmex('mllib::subsref',A.s,inds{:});

Error in ==> lunar at 4
if ((x(6)/x(5))*cos(atan(x(7)/x(6)))+(x(7)/x(5))*sin(atan(x(7)/x(6)))-(3.283e-4)*x(10))+1>0
回复此楼

» 猜你喜欢

» 本主题相关价值贴推荐,对您同样有帮助:

已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

wzycrfpxz

新虫 (初入文坛)

引用回帖:
4楼: Originally posted by csgt0 at 2012-08-23 10:22:14
你怎么调用函数的?你这是一个函数,得用别的数据调用,比如你在命令窗口输入以下试试:
x=ones(1,7);
t=1;
u=2;
dx=lunar(t,x,u);
这样就可以运行了。但是你的t和u好像根本与外面没有关系,因为再里面计算了
...

function dx=lunar(t,x)

if ((x(6)/x(5))*cos(atan(x(7)/x(6)))+(x(7)/x(5))*sin(atan(x(7)/x(6)))-(3.283e-4)*x(10))+1>0
    u=45760.00;

else   u=0.00

dx=[(u/x(5))*cos(atan(x(7)/x(6)));
    (u/x(5))*sin(atan(x(7)/x(6)));
    x(1);
    x(2);
    (-3.281e-4)*u;
    0;
    -x(9);
    0;
    0;
    (u/x(5)^2)*cos(atan(x(7)/x(6)))*x(6)+(u/x(5)^2)*sin(atan(x(7)/x(6)))*x(7)];

end



命令窗口:x0=[150;-44;0;2300;9472.06;0.005;-0.003501;0;5.415e-4;1];
tic,[t,y]=ode45(@lunar,[0,100],x0);toc


Error in ==> lunar at 3
if ((x(6)/x(5))*cos(atan(x(7)/x(6)))+(x(7)/x(5))*sin(atan(x(7)/x(6)))-(3.283e-4)*x(10))+1>0

??? Error using ==> feval
Output argument "dx" (and maybe others) not assigned during call to "C:\Users\Administrator\Documents\MATLAB\lunar.m>lunar".

Error in ==> odearguments at 110
f0 = feval(ode,t0,y0,args{:});   % ODE15I sets args{1} to yp0.

Error in ==> ode45 at 173
[neq, tspan, ntspan, next, t0, tfinal, tdir, y0, f0, odeArgs, odeFcn, ..
6楼2012-08-23 10:24:03
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
查看全部 8 个回答

csgt0

荣誉版主 (著名写手)

彩色挂图

【答案】应助回帖


感谢参与,应助指数 +1
wzycrfpxz: 金币+1, 有帮助 2012-08-23 11:23:26
把syms t x u;这句删掉
showmethemoney
2楼2012-08-23 10:02:49
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

wzycrfpxz

新虫 (初入文坛)

引用回帖:
2楼: Originally posted by csgt0 at 2012-08-23 10:02:49
把syms t x u;这句删掉

??? Input argument "x" is undefined.

Error in ==> lunar at 4
if ((x(6)/x(5))*cos(atan(x(7)/x(6)))+(x(7)/x(5))*sin(atan(x(7)/x(6)))-(3.283e-4)*x(10))+1>0
删掉以后出现这个问题
3楼2012-08-23 10:06:51
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

csgt0

荣誉版主 (著名写手)

彩色挂图

【答案】应助回帖

你怎么调用函数的?你这是一个函数,得用别的数据调用,比如你在命令窗口输入以下试试:
x=ones(1,7);
t=1;
u=2;
dx=lunar(t,x,u);
这样就可以运行了。但是你的t和u好像根本与外面没有关系,因为再里面计算了
所以你可以改成
dx=lunar(x)
showmethemoney
4楼2012-08-23 10:22:14
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[考研] 求调剂 +10 月@163.com 2026-04-07 12/600 2026-04-11 20:44 by going home
[考研] 283求调剂 086004考英二数二 +17 那个噜子 2026-04-10 18/900 2026-04-11 16:27 by 明月此时有
[考研] 347求调剂 +3 mhyqyy 2026-04-06 3/150 2026-04-11 12:19 by zhq0425
[考研] 0854调剂 +11 长弓傲 2026-04-09 12/600 2026-04-11 11:16 by zhq0425
[考研] 调剂 +4 电气300求调剂不 2026-04-08 7/350 2026-04-11 10:44 by 紫曦紫棋
[考研] 292求调剂 +9 笑笑袁 2026-04-09 9/450 2026-04-10 10:05 by LHGeng
[考研] 材料与化工371求调剂 +17 陪琳看海 2026-04-04 18/900 2026-04-10 07:51 by 314126402
[考研] 本科郑州大学,一志愿华东师范大学282求调剂 +23 熊哥xtk 2026-04-07 26/1300 2026-04-09 17:17 by 18446523
[考研] 求调剂材料科学与工程一志愿985初试365分 +5 材化李可 2026-04-08 5/250 2026-04-09 17:00 by Lilly_Li
[考研] 274求调剂 +5 山阿蔓 2026-04-07 5/250 2026-04-09 15:28 by 18828373951
[考研] 086000生物与医药调剂 +7 awwwwwooooo 2026-04-09 7/350 2026-04-09 13:31 by 北极159263
[考研] 求调剂 +7 chenxrlkx 2026-04-05 9/450 2026-04-09 09:04 by wj165256
[考研] 求调剂 +8 吃口冰激凌 2026-04-07 8/400 2026-04-09 08:03 by 5268321
[考研] 一志愿华南师范大学0702物理学305调剂 +4 念常安 2026-04-07 6/300 2026-04-08 22:53 by bljnqdcc
[考研] 323求调剂 +3 林zlu 2026-04-07 4/200 2026-04-07 23:21 by lbsjt
[考研] 22408 调剂材料 +7 我叫ez 2026-04-06 8/400 2026-04-07 17:12 by 蓝云思雨
[考研] 081200-11408-367学硕求调剂 +4 1_2_3111 2026-04-06 4/200 2026-04-07 08:13 by jp9609
[考研] 338求调剂 +4 我想上岸ii 2026-04-05 4/200 2026-04-06 21:04 by 木子君1218
[考研] 复试调剂 +5 asdasdassda 2026-04-05 5/250 2026-04-06 09:32 by dongzh2009
[考研] 328分调剂 +6 门men 2026-04-04 6/300 2026-04-05 13:40 by imissbao
信息提示
请填处理意见