| 5 | 1/1 | 返回列表 |
| 查看: 2209 | 回復: 6 | ||
| 【懸賞金幣】回答本帖問題,作者小蟲飛更高將贈送您 5 個金幣 | ||
| 當前只顯示滿足指定條件的回帖,點擊這里查看本話題的所有回帖 | ||
[求助]
matlab光強編程,提示矩陣維度 必須一致,不知是哪里出現(xià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)錯誤如下: 矩陣維度必須一致。 出錯 formula>@(theta)(1+cos(theta))./(1-cos(theta)).*sin(theta).*Besselk(2,k.*r.*sin(theta)) 出錯 quadl (line 62) y = feval(f,x,varargin{:}); y = y( .';出錯 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; |
至尊木蟲 (著名寫手)

至尊木蟲 (著名寫手)

送紅花一朵 |
你好,我按照你的編程輸入了下,還是有提示錯誤,請你在幫我解答下, 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 提示錯誤如下: formula ans = 0.5000 未定義與 'double' 類型的輸入?yún)?shù)相對應的函數(shù) 'Besselk'。 出錯 formula>@(theta)(1+cos(theta))./(1-cos(theta)).*sin(theta).*Besselk(2,k.*r0.*sin(theta)) 出錯 quadl (line 62) y = feval(f,x,varargin{:}); y = y( .';出錯 formula (line 13) eq=quadl(@(theta)(1+cos(theta))./(1-cos(theta)).*sin(theta).*Besselk(2,k.*r0.*sin(theta)),2.23,pi); >> |
|
剛我又調試了下,出現(xiàn)如下錯誤,您再幫我看下: 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 提示錯誤: 定義變量 "real" 或類 "real"。 出錯 para (line 22) mesh(x1,y1,real(I).C);hold on |
| 最具人氣熱帖推薦 [查看全部] | 作者 | 回/看 | 最后發(fā)表 | |
|---|---|---|---|---|
|
[考研] 一志愿湖師大化學289求調劑 +3 | XMCMM3.14159 2026-03-10 | 3/150 |
|
|---|---|---|---|---|
|
[考博] 求材料讀博院校 +9 | yanglei131 2026-03-08 | 9/450 |
|
|
[考研] 新疆大學地質與礦業(yè)工程學院招生 +24 | another12 2026-03-04 | 32/1600 |
|
|
[考研] 標題:撿漏預警|08工科/09農(nóng)學調劑!英語要求低,過線即有機會! +4 | 馬超放煙花 2026-03-07 | 4/200 |
|
|
[考研] 310 070300化學求調劑 +4 | 撲風鈴的貓 2026-03-08 | 5/250 |
|
|
[考研] 0703化學求調劑 +4 | 很老實人 2026-03-09 | 4/200 |
|
|
[考研] 求調劑,一志愿華中科大0702,數(shù)一英一,293 +4 | 小羅露一二 2026-03-07 | 4/200 |
|
|
[考研] 085701環(huán)境工程專業(yè),初試305,均過國家A區(qū)線 +7 | 卡卡來了@ 2026-03-07 | 8/400 |
|
|
[考研] 第一志愿上海大學,專業(yè)化學工程與技術,總分288,求調劑 +3 | 1829197082 2026-03-07 | 3/150 |
|
|
[考研] 一志愿211 085600 280數(shù)二英二求調劑 +3 | 月山斜 2026-03-06 | 3/150 |
|
|
[考研] 一志愿哈爾濱工業(yè)大學0856材料與化工,前三科206,總分283,求調劑 +7 | 26考研求調劑 2026-03-06 | 7/350 |
|
|
[考研] 材料與化工354調劑 +4 | Lucy-xiao 2026-03-06 | 7/350 |
|
|
[考研] 275求調劑 +4 | 大爆炸難民 2026-03-06 | 5/250 |
|
|
[考研] 085600,一志愿鄭州大學,280分求調劑 +7 | Wuqi725 2026-03-05 | 7/350 |
|
|
[考研] 考研282分求調劑,接受跨專業(yè) +4 | 劉淄博 2026-03-04 | 7/350 |
|
|
[考研] 材料085601一志愿哈工大317 +4 | 壓迫感行 2026-03-04 | 4/200 |
|
|
[考研] 求調劑 +3 | 泡了個椒 2026-03-04 | 4/200 |
|
|
[考研] 320材料一志愿西工大專碩英二數(shù)二 有兩年光伏工作經(jīng)驗 +5 | 錘某人 2026-03-04 | 8/400 |
|
|
[考研] 325求調劑 +5 | 學家科 2026-03-04 | 5/250 |
|
|
[考研] 281求調劑 +3 | Y?l?h 2026-03-04 | 3/150 |
|