| 5 | 1/1 | 返回列表 |
| 查看: 2204 | 回復(fù): 6 | |||
| 【懸賞金幣】回答本帖問(wèn)題,作者小蟲(chóng)飛更高將贈(zèng)送您 5 個(gè)金幣 | |||
| 當(dāng)前只顯示滿足指定條件的回帖,點(diǎn)擊這里查看本話題的所有回帖 | |||
小蟲(chóng)飛更高新蟲(chóng) (初入文壇)
|
[求助]
matlab光強(qiáng)編程,提示矩陣維度 必須一致,不知是哪里出現(xiàn)的問(wèn)題,代碼在下面 已有1人參與
|
||
|
代碼如下: clear all; k=10; f=1004.8; x=-1.5:0.01:1.5; y=-1.5:0.01:1.5; [x1,y1]=meshgrid(x,y); r=sqrt(x1.^2+y1.^2); Phi=atan(y1./x1); I=(i*k*exp(i*(pi/2+k*f)).*sin(2.*Phi).*quadl(@(theta)(1+cos(theta))./(1-cos(theta)).*sin(theta).*Besselk(2,k.*r.*sin(theta)),2.23,pi)).^2; subplot(2,1,1); mesh(x1,y1,I); axis([-1.5 1.5 -1.5 1.5 0 1]); subplot(2,1,2); subimage(I*255); axis off; 出現(xiàn)錯(cuò)誤如下: 矩陣維度必須一致。 出錯(cuò) formula>@(theta)(1+cos(theta))./(1-cos(theta)).*sin(theta).*Besselk(2,k.*r.*sin(theta)) 出錯(cuò) quadl (line 62) y = feval(f,x,varargin{:}); y = y( .';出錯(cuò) formula (line 9) I=(i*k*exp(i*(pi/2+k*f)).*sin(2.*Phi).*quadl(@(theta)(1+cos(theta))./(1-cos(theta)).*sin(theta).*Besselk(2,k.*r.*sin(theta)),2.23,pi)).^2; |
新蟲(chóng) (初入文壇)
|
剛我又調(diào)試了下,出現(xiàn)如下錯(cuò)誤,您再幫我看下: k=10; f=1004.8; x=-0.5:0.01:0.5; y=-0.5:0.01:0.5; [x1,y1]=meshgrid(x,y); r=sqrt(x1.^2+y1.^2); [K,L]=size(r); for m=1:k for n=1:L Phi=atan(y1(n)./x1(m)); r0=r(m,n); eq=quadl(@(theta)(1+cos(theta))./(1-cos(theta)).*sin(theta).*besselk(2,k.*r0.*sin(theta)),2.23,pi); I0=(i*k*exp(i*(pi/2+k*f))*sin(2*Phi)*eq)^2; I(m,n)=I0; end end Re=real(I);Im=imag(I); s.FaceColor='flat'; %subplot(2,1,1); C=rand(K,L); mesh(x1,y1,real(I).C);hold on axis([-1.5 1.5 -1.5 1.5 0 1]); subplot(2,1,2); subimage(I*255); axis off 提示錯(cuò)誤: 定義變量 "real" 或類(lèi) "real"。 出錯(cuò) para (line 22) mesh(x1,y1,real(I).C);hold on |
至尊木蟲(chóng) (著名寫(xiě)手)

新蟲(chóng) (初入文壇)
送紅花一朵 |
你好,我按照你的編程輸入了下,還是有提示錯(cuò)誤,請(qǐng)你在幫我解答下, clear all; k=10; f=1004.8; x=-0.5:0.01:0.5; y=-0.5:0.01;0.5 [x1,y1]=meshgrid(x,y); r=sqrt(x1.^2+y1.^2); [K,L]=size(r); for m=1:k for n=1:L Phi=atan(y1(n)./x1(m)); r0=r(m,n); eq=quadl(@(theta)(1+cos(theta))./(1-cos(theta)).*sin(theta).*Besselk(2,k.*r0.*sin(theta)),2.23,pi); I0=(i*k*exp(i*(pi/2+k*f))*sin(2*Phi)*eq).^2; I(m,n)=I0; end end Re=real(I);Im=imag(I); s.FaceColor='flat'; %subplot(2,1,1); C=rand(K,L); mesh(x1,y1,real(I).C);hold on 提示錯(cuò)誤如下: formula ans = 0.5000 未定義與 'double' 類(lèi)型的輸入?yún)?shù)相對(duì)應(yīng)的函數(shù) 'Besselk'。 出錯(cuò) formula>@(theta)(1+cos(theta))./(1-cos(theta)).*sin(theta).*Besselk(2,k.*r0.*sin(theta)) 出錯(cuò) quadl (line 62) y = feval(f,x,varargin{:}); y = y( .';出錯(cuò) formula (line 13) eq=quadl(@(theta)(1+cos(theta))./(1-cos(theta)).*sin(theta).*Besselk(2,k.*r0.*sin(theta)),2.23,pi); >> |
至尊木蟲(chóng) (著名寫(xiě)手)
|
real是函數(shù),應(yīng)該不存在定義變量的問(wèn)題?赡苁擒浖膯(wèn)題,重啟試一試看。 |

| 最具人氣熱帖推薦 [查看全部] | 作者 | 回/看 | 最后發(fā)表 | |
|---|---|---|---|---|
|
[考博] 申博 +5 | 添菜了哈 2026-03-04 | 8/400 |
|
|---|---|---|---|---|
|
[考研] 296求調(diào)劑 +3 | Xinyu Wu311 2026-03-09 | 3/150 |
|
|
[考研] 348求調(diào)劑 +3 | wyx79618 2026-03-06 | 6/300 |
|
|
[考博] 26申博自薦 +9 | 烷基八氮- 2026-03-06 | 11/550 |
|
|
[基金申請(qǐng)] 請(qǐng)問(wèn)大家,研究風(fēng)險(xiǎn)與應(yīng)對(duì)措施那里, 大家都怎么寫(xiě)呢 ? +5 | cauasen 2026-03-02 | 6/300 |
|
|
[考研] 安徽農(nóng)業(yè)大學(xué)材料與化學(xué)學(xué)院0856材料招收調(diào)劑 +3 | akakk47 2026-03-05 | 9/450 |
|
|
[考研] 求調(diào)劑,不管什么專(zhuān)業(yè),我是可塑造的人才一枚,希望遇到知己老師撈撈我 +4 | 13102137290 2026-03-06 | 5/250 |
|
|
[考研] 276求調(diào)劑 本科天津工業(yè)大學(xué) 一志愿北京化工大學(xué)0855 +4 | 路lyh123 2026-03-06 | 6/300 |
|
|
[考研] 275求調(diào)劑 +4 | 大爆炸難民 2026-03-06 | 5/250 |
|
|
[考研] 316求調(diào)劑 +3 | 林小星發(fā)大財(cái) 2026-03-05 | 5/250 |
|
|
[考研] 283求調(diào)劑 +10 | 鹿沫笙 2026-03-02 | 11/550 |
|
|
[考研] 材料學(xué)碩080500復(fù)試調(diào)劑294 +3 | 四葉zjz 2026-03-04 | 3/150 |
|
|
[考研] 一志愿鄭州大學(xué),學(xué)碩,物理化學(xué), 333求調(diào)劑 +5 | 李魔女斗篷 2026-03-04 | 5/250 |
|
|
[考研] 0857求調(diào)劑 +4 | CDDD1013 2026-03-04 | 4/200 |
|
|
[考研] 085601 材料工程 320 +6 | 和樂(lè)瑤 2026-03-03 | 6/300 |
|
|
[考研] 一志愿西交大材料學(xué)碩 346 求調(diào)劑 +3 | zju51 2026-03-04 | 3/150 |
|
|
[考研] 264求調(diào)劑 +3 | thext 2026-03-03 | 3/150 |
|
|
[考研] 理學(xué),工學(xué),農(nóng)學(xué)調(diào)劑,少走彎路,這里歡迎您! +8 | likeihood 2026-03-02 | 11/550 |
|
|
[考研] 290求調(diào)劑 +9 | ErMiao1020 2026-03-02 | 9/450 |
|
|
[考研] 11408,學(xué)碩276求調(diào)劑 +3 | 崔wj 2026-03-02 | 5/250 |
|