24小时热门版块排行榜    

北京石油化工学院2026年研究生招生接收调剂公告
查看: 679  |  回复: 2

ldoop

铁杆木虫 (著名写手)


[求助] matlab 程序问题

各位大虾们帮忙看段程序,每次运行总是出现这样的错误:
Improper assignment with rectangular empty matrix.

Error in improved2 (line 56)
                         c(z)=find(divergentsp==b(z));
此时的值 b=4, c=[]
请问怎么调试,另外如何简化这段程序?万分感谢

源程序如下:
if abundance(species)==1
             if species~=S
                 b=find(divergentsp==species);
                 if isempty(b)~= 1
                     divergentsp(b)=b(1)-1;
                     divergentsp(b(1))=divergentsp(species);
                     for z=1:length(b)
                         c(z)=find(divergentsp==b(z));
                         divergentsp(divergentsp==b(z))=divergentsp(divergentsp==b(z))-1;
                         if isempty(c(z))~=1
                             for x=1:length(c(z))
                                 d(x)=find(divergentsp==c(x));
                                 divergentsp(divergentsp==c(x))=divergentsp(divergentsp==c(x))-1;
                                 if isempty(d(x))~=1
                                     for y=1:length(d(x))
                                         e(y)=find(divergentsp==d(y));
                                         divergentsp(divergentsp==d(y))=divergentsp(divergentsp==d(y))-1;
                                         if isempty(e(y))~=1
                                             for w=1:length(e(y))
                                                 f(w)=find(divergentsp==e(w));
                                                 divergentsp(divergentsp==e(w))=divergentsp(divergentsp==e(w))-1;
                                                 if isempty(f(w))~=1
                                                     g(u)=find(divergentsp(divergentsp==f(u)));
                                                     divergentsp(divergentsp==f(u))=divergentsp(divergentsp==f(u))-1;
                                                     if isempty(g(u))~=1
                                                         for q=1:length(g(u))
                                                             h(q)=find(divergentsp(divergentsp==g(q)))
                                                             divergentsp(divergentsp==g(q))=divergentsp(divergentsp==g(q))-1;
                                                             if isempty(h(q))~=1
                                                                 for l=1:length(h(q))
                                                                     divergentsp(divergentsp==h(l))=divergentsp(divergentsp==h(l))-1;
                                                                 end
                                                             end
                                                         end
                                                     end
                                                 end
                                             end
                                         end
                                     end
                                 end
                             end
                         end
                     end
                 end
             end
回复此楼

» 猜你喜欢

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

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

emanlee

木虫 (小有名气)

【答案】应助回帖


感谢参与,应助指数 +1
jjdg: 金币+1, 感谢参与 2012-03-21 01:42:44
你的程序我放到matlab中,编译说至少缺了一个end,我加上end之后。
再编译,Undefined function or variable 'species'. 该程序不完整不好调试。

如果要调试,可以设置断点,然后,一句一句运行程序。
2楼2012-03-20 18:13:52
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

Love_Matrix

木虫 (正式写手)

【答案】应助回帖


感谢参与,应助指数 +1
jjdg: 金币+1, 感谢参与 2012-03-21 01:42:55
复制的把,需要15个end,少两个
3楼2012-03-20 21:21:16
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
相关版块跳转 我要订阅楼主 ldoop 的主题更新
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[考研] 0703调剂 +12 拾玖壹 2026-04-04 13/650 2026-04-06 06:26 by houyaoxu
[考研] 求调剂 +11 熊二想上岸 2026-04-04 11/550 2026-04-05 22:21 by 醉翁wl
[考研] 材料调剂 +13 一样YWY 2026-04-03 14/700 2026-04-05 18:20 by 蓝云思雨
[考研] 275求调剂 +16 waltzh 2026-04-01 16/800 2026-04-05 17:14 by Hdyxbekcb
[考研] 358求调剂 +7 秋gk 2026-04-04 7/350 2026-04-05 13:29 by huangmoli
[考研] 288环境专硕,求调材料方向 +13 lllllos 2026-04-04 14/700 2026-04-04 23:34 by lqwchd
[考研] +5 雾与海 2026-04-02 6/300 2026-04-04 19:53 by 蓝云思雨
[考研] 309分085801求调剂 +11 MY_angel 2026-03-31 11/550 2026-04-04 19:11 by 蓝云思雨
[考研] 22408,264求调剂 +3 ywh729 2026-04-03 4/200 2026-04-04 11:04 by ywh729
[考研] 材料295 +13 小英11 2026-04-03 14/700 2026-04-04 09:02 by 来看流星雨10
[考研] 085501一志愿天工大,机械专硕求调剂,跨材料 +3 33上 2026-04-03 3/150 2026-04-03 14:08 by 1753564080
[考研] 303求调剂 +3 一色清羽 2026-04-02 4/200 2026-04-03 10:22 by 蓝云思雨
[考研] 一志愿陕西师范大学生物学317分 +5 1563日。 2026-04-02 5/250 2026-04-03 06:58 by ilovexiaobin
[考研] 求调剂 302分初试 0854 +5 伶可乐 2026-04-02 5/250 2026-04-02 17:53 by 笔落锦州
[考研] 一志愿北交大材料工程总分358 +3 cs0106 2026-04-02 5/250 2026-04-02 11:37 by olim
[考研] 材料调剂 +11 一样YWY 2026-03-31 11/550 2026-04-01 22:25 by zhouyuwinner
[考研] 379求调剂 +3 ?苦瓜不苦 2026-04-01 3/150 2026-04-01 20:09 by 暮云清寒
[考研] 085600,321分求调剂 +13 大馋小子 2026-03-31 13/650 2026-04-01 12:35 by chemdavid
[考研] 318求调剂 +8 七忆77 2026-04-01 8/400 2026-04-01 10:37 by Jaylen.
[考研] 本科211总分289,08工学真心求调剂 +3 utopiaE 2026-03-30 3/150 2026-03-30 23:42 by ms629
信息提示
请填处理意见