| 7 | 1/1 | 返回列表 |
| 查看: 2200 | 回復(fù): 6 | ||
| 【懸賞金幣】回答本帖問題,作者小蟲飛更高將贈(zèng)送您 5 個(gè)金幣 | ||
小蟲飛更高新蟲 (初入文壇)
|
[求助]
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)錯(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; |
至尊木蟲 (著名寫手)

新蟲 (初入文壇)
送紅花一朵 |
你好,我按照你的編程輸入了下,還是有提示錯(cuò)誤,請你在幫我解答下, 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' 類型的輸入?yún)?shù)相對應(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); >> |
新蟲 (初入文壇)
|
剛我又調(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" 或類 "real"。 出錯(cuò) para (line 22) mesh(x1,y1,real(I).C);hold on |
至尊木蟲 (著名寫手)

新蟲 (初入文壇)
送紅花一朵 |
我試了試其他筆記本的電腦上的版本matlab,還是提示未定義變量‘real ’或類‘real’,請您運(yùn)行下我的程序,看看是什么問題呢? |
新蟲 (初入文壇)
|
定義變量的問題解決了,但是又遇到了一個(gè)索引函數(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 錯(cuò)誤: 不能使用 {} 或 . 索引為函數(shù)編制索引。 出錯(cuò) para (line 25) mesh(x1,y1,real(I).C); |
| 7 | 1/1 | 返回列表 |
| 最具人氣熱帖推薦 [查看全部] | 作者 | 回/看 | 最后發(fā)表 | |
|---|---|---|---|---|
|
[教師之家] 交大前校長王樹國:現(xiàn)在最先進(jìn)的科技并不在大學(xué)實(shí)驗(yàn)室,而是在企業(yè)研究院 +3 | zju2000 2026-03-08 | 4/200 |
|
|---|---|---|---|---|
|
[考研] 0856材料與化工290求調(diào)劑 +3 | Nebulala 2026-03-08 | 4/200 |
|
|
[考研] 085700資環(huán)求調(diào)劑,初始279,六級已過,英語能力強(qiáng) +4 | 085700資環(huán)調(diào)劑 2026-03-03 | 5/250 |
|
|
[考研] 08工科 +4 | li李樂成 2026-03-06 | 4/200 |
|
|
[考研] 267化工調(diào)劑求助 +7 | 聰少OZ 2026-03-04 | 7/350 |
|
|
[考博] 26申博-目前4篇SCI一作 +4 | chen_2024 2026-03-02 | 4/200 |
|
|
[考研] 求調(diào)劑,學(xué)校研究所都可以,材料與化工267分 +6 | wmx1 2026-03-05 | 6/300 |
|
|
[考研] 求材料調(diào)劑 +4 | berdmond 2026-03-05 | 4/200 |
|
|
[考研] 304求調(diào)劑 +4 | 曼殊2266 2026-03-05 | 4/200 |
|
|
[考研] 0856材料與化工,270求調(diào)劑 +17 | YXCT 2026-03-01 | 20/1000 |
|
|
[考研] 0855機(jī)械工程324求調(diào)劑 +3 | 鄭SK 2026-03-02 | 7/350 |
|
|
[考研] 295求調(diào)劑 +6 | 等春來, 2026-03-04 | 6/300 |
|
|
[考研] 能動(dòng)297求調(diào)劑,本科川大 +4 | 邵11 2026-03-04 | 4/200 |
|
|
[考研] 331求調(diào)劑 +3 | zzZ&zZ 2026-03-03 | 3/150 |
|
|
[考研] 292求調(diào)劑 +3 | sgbl 2026-03-03 | 3/150 |
|
|
[考研] 調(diào)劑 +5 | 13853210211 2026-03-02 | 7/350 |
|
|
[考研] 化工京區(qū)271求調(diào)劑 +7 | 11ing 2026-03-02 | 7/350 |
|
|
[考研] 求調(diào)劑 +11 | yunziaaaaa 2026-03-01 | 13/650 |
|
|
[考研] 291 求調(diào)劑 +3 | 化工2026屆畢業(yè)?/a> 2026-03-02 | 3/150 |
|
|
[基金申請] 此成果不能導(dǎo)入原因:元數(shù)據(jù)必填信息不完整,可 進(jìn)行補(bǔ)充。 +4 | Kittylucky 2026-03-02 | 5/250 |
|