| 5 | 1/1 | 返回列表 |
| 查看: 2211 | 回復(fù): 6 | |||
| 【懸賞金幣】回答本帖問題,作者小蟲飛更高將贈送您 5 個金幣 | |||
| 當(dāng)前只顯示滿足指定條件的回帖,點(diǎn)擊這里查看本話題的所有回帖 | |||
小蟲飛更高新蟲 (初入文壇)
|
[求助]
matlab光強(qiáng)編程,提示矩陣維度 必須一致,不知是哪里出現(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; |
新蟲 (初入文壇)
|
定義變量的問題解決了,但是又遇到了一個索引函數(shù)編制的問題,問題在代碼后面: clear all; close all; clc; k=10; f=1004.8; x=-0.5:0.01:0.5; y=-0.5:0.01:0.5; [x1,y1]=meshgrid(x,y);%直角坐標(biāo)轉(zhuǎn)化為極坐標(biāo) 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 錯誤: 不能使用 {} 或 . 索引為函數(shù)編制索引。 出錯 para (line 25) mesh(x1,y1,real(I).C); |
至尊木蟲 (著名寫手)

新蟲 (初入文壇)
送紅花一朵 |
你好,我按照你的編程輸入了下,還是有提示錯誤,請你在幫我解答下, 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ù)相對應(yīng)的函數(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); >> |
新蟲 (初入文壇)
|
剛我又調(diào)試了下,出現(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ā)表 | |
|---|---|---|---|---|
|
[考研] 288求調(diào)劑 +11 | 王曉陽- 2026-03-09 | 16/800 |
|
|---|---|---|---|---|
|
[考研] 0857環(huán)境調(diào)劑 +3 | 熠熠_11 2026-03-10 | 3/150 |
|
|
[考研] 一志愿安徽大學(xué)材料工程專碩313分,求調(diào)劑的學(xué)校 +5 | Yu先生 2026-03-10 | 5/250 |
|
|
[考研] 一志愿天大化工(085600)調(diào)劑總分338 +5 | 蔡大美女 2026-03-09 | 5/250 |
|
|
[考研] 一志愿:武漢理工,材料工程,英二數(shù)二 總分314 +3 | 2202020125 2026-03-10 | 4/200 |
|
|
[考研] 研究生招生 +3 | 徐海濤11 2026-03-10 | 6/300 |
|
|
[碩博家園] 2026級碩士研究生招生/調(diào)劑 +4 | lbj6746988 2026-03-03 | 7/350 |
|
|
[考研] 0703求調(diào)劑 +10 | c297914 2026-03-06 | 11/550 |
|
|
[基金申請] 第二個面上項(xiàng)目的獲批幾率如何? +3 | wawm9296 2026-03-04 | 5/250 |
|
|
[考博] 申博 +5 | 添菜了哈 2026-03-04 | 8/400 |
|
|
[考研] 一志愿武理314求調(diào)劑 +4 | ( ̄~ ̄;) 2026-03-08 | 5/250 |
|
|
[考研] 083000環(huán)境科學(xué)與工程調(diào)劑 +5 | 加油呀fxy 2026-03-07 | 6/300 |
|
|
[考研] 材料工程307,求調(diào)劑 +4 | 我要燃燒你的夢 2026-03-08 | 4/200 |
|
|
[考研] 安徽農(nóng)業(yè)大學(xué)材料與化學(xué)學(xué)院0856材料招收調(diào)劑 +3 | akakk47 2026-03-05 | 9/450 |
|
|
[考研] 287求調(diào)劑 +3 | 看看我. 2026-03-05 | 6/300 |
|
|
[考研] 275求調(diào)劑 +4 | 大爆炸難民 2026-03-06 | 5/250 |
|
|
[考研] 求調(diào)劑 +5 | danyyyy 2026-03-04 | 5/250 |
|
|
[考研] 332材料求調(diào)劑 +6 | zjy101327 2026-03-05 | 7/350 |
|
|
[考研] 070300化學(xué) 280 一志愿太原理工 求調(diào)劑 +8 | 拾玖壹 2026-03-04 | 8/400 |
|
|
[考研] 材料學(xué)碩080500復(fù)試調(diào)劑294 +3 | 四葉zjz 2026-03-04 | 3/150 |
|