| 5 | 1/1 | 返回列表 |
| 查看: 2208 | 回復: 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; |
|
剛我又調試了下,出現(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 |
至尊木蟲 (著名寫手)

送紅花一朵 |
你好,我按照你的編程輸入了下,還是有提示錯誤,請你在幫我解答下, 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); >> |
至尊木蟲 (著名寫手)

| 最具人氣熱帖推薦 [查看全部] | 作者 | 回/看 | 最后發(fā)表 | |
|---|---|---|---|---|
|
[考研] 收調劑 +3 | 調劑的考研學生 2026-03-10 | 3/150 |
|
|---|---|---|---|---|
|
[考研] 282分材料專業(yè)求調劑院校 +14 | 楓橋ZL 2026-03-09 | 20/1000 |
|
|
[考研] 288求調劑 +10 | 王曉陽- 2026-03-09 | 15/750 |
|
|
[考研] 一志愿北京化工大學材料與化工296分求調劑 +9 | 稻妻小編 2026-03-09 | 9/450 |
|
|
[考研] 一志愿山東大學105500藥學專碩,總分302求調劑 +5 | 五維天空 2026-03-04 | 12/600 |
|
|
[考研] 考研一志愿長安大學材料與化工309分請求調劑 +6 | dtdxzxx 2026-03-06 | 8/400 |
|
|
[考研] 新疆大學地質與礦業(yè)工程學院招生 +24 | another12 2026-03-04 | 32/1600 |
|
|
[考研] 數(shù)二英二309分請求調劑 +3 | dtdxzxx 2026-03-09 | 4/200 |
|
|
[考研] 一志愿山東大學,總分327,英語二79,有論文,有競賽,已過四六級 +3 | 木木目目1 2026-03-09 | 3/150 |
|
|
[考研] 一志愿南大化學339分求調劑,四六級已過,有比賽,有文章 +7 | Gallantzhou 2026-03-07 | 7/350 |
|
|
[考研] 求調劑,數(shù)一英一274分 +4 | 小菲會努力 2026-03-08 | 4/200 |
|
|
[考研] 085701環(huán)境工程專業(yè),初試305,均過國家A區(qū)線 +7 | 卡卡來了@ 2026-03-07 | 8/400 |
|
|
[考研] 0307化學求調劑 +6 | 0ok0k 2026-03-07 | 6/300 |
|
|
[考研] 誠求調劑,323分 有專利/科研/實習經(jīng)歷 +6 | 橙子cyx 2026-03-06 | 8/400 |
|
|
[考研] 085600材料與化工 298 調劑 +11 | 小西笑嘻嘻 2026-03-03 | 11/550 |
|
|
[考研]
|
程晴之 2026-03-06 | 6/300 |
|
|
[考研] 材料與化工354調劑 +4 | Lucy-xiao 2026-03-06 | 7/350 |
|
|
[考研] 材料與化工304求調劑 +7 | 邱gl 2026-03-05 | 10/500 |
|
|
[考研] 求調劑 +3 | 泡了個椒 2026-03-04 | 4/200 |
|
|
[考研] 298求調劑 +3 | 人間唯你是清歡 2026-03-03 | 4/200 |
|