| 查看: 4315 | 回復(fù): 10 | ||
[求助]
求助matlab for循環(huán)中的賦值問題。 已有2人參與
|
||
|
dm=0.001*2*pi*c; w=-0.5*2*pi*c:dm:0.5*2*pi*c; Kx=zeros(size(w)); Ay=zeros(size(w)); for m=1:length(w); syms ay kx ky; y=(0.0382*8*(pi^3)*(c^4)*sqrt(ainf-(wp.^2)./(w.^2)))./((wp^2).*w); axx=ainf*((1-(wp*(w+1i*y)*wp))./(w.*(((w+1i*y).^2)-((wc)^2)))); %無單位 axy=ainf*(((wp^2)*wc*1i)./(w.*(((w+y*1i).^2)-((wc)^2)))); %無單位 azz=ainf.*((1-(wp^2))./(w.*(w+1i*y))); %無單位 a1=real(axx); a2=imag(axx); a3=real(axy); a4=imag(axy); a5=real(azz); a6=imag(azz); f1=ay-sqrt((kx.^2)-((w./c).^2)); f2=kx-((sqrt(((a4.*ay./2).^2))+(a1.*(w./c).^2)-((a1.*ay.*ky)./(tan(ky.*t))))-(a4.*ay./2)); f3=ky-(sqrt((((w./c).^2).*(a1-((a4.^2)./a1)))-kx.^2)); [kx,ay]=solve('f1','f2','f3'); Kx(m)=kx; Ay(m)=Ay; end 運行提示:在賦值 A( = B 中,A 和 B 中的元素數(shù)目必須相同。出錯行數(shù): Kx(m)=kx; Ay(m)=Ay; 跪求大神解惑。。。 |
金蟲 (正式寫手)
|
solve函數(shù),不能計算點乘,建議你采用solve函數(shù)計算出來函數(shù)關(guān)系式,然后手動輸入方程再操作 發(fā)自小木蟲Android客戶端 |
至尊木蟲 (知名作家)
|
https://www.mathworks.com/help/symbolic/solve.html Return Numeric Solutions Try solving the following equation. The symbolic solver cannot find an exact symbolic solution for this equation, and therefore issues a warning before calling the numeric solver. Because the equation is not polynomial, an attempt to find all possible solutions can take a long time. The numeric solver does not try to find all numeric solutions for this equation. Instead, it returns only the first solution it finds. |
|
我把點乘去掉顯示: 在賦值 A( = B 中,A 和 B 中的元素數(shù)目必須相同。我重新編了一下solve的公式: kx=solve(tan(t*(((sqrt(((w(m)/c)^2)*(a1-((a4^2)/a1)))))-(kx^2)))==(a1*sqrt(((w(m)/c)^2)*(a1-((a4^2)/a1))-(kx^2))*sqrt((kx^2)-((w(m)/c)^2)))/((a1*((w(m)/c)^2))-(kx^2)-(a4*kx*sqrt((kx^2)-((w(m)/c)^2)))),kx); 但是在kx賦值到Kx的時候出現(xiàn)錯誤,另外,solve語句單獨拿出來進(jìn)行計算的時候會出現(xiàn)警告: 警告: Cannot solve symbolically. Returning a numeric approximation instead. 這個時候我能輸出kx。很疑惑。 |
|
大神,這個我了解了,所以嘗試把solve語句修改了一下,單獨計算kx=solve(tan(t*(((sqrt(((w/c)^2)*(a1-((a4^2)/a1)))))-(kx^2)))==(a1*sqrt(((w/c)^2)*(a1-((a4^2)/a1))-(kx^2))*sqrt((kx^2)-((w/c)^2)))/((a1*((w/c)^2))-(kx^2)-(a4*kx*sqrt((kx^2)-((w/c)^2)))),kx);時,現(xiàn)出現(xiàn)警告: 警告: Cannot solve symbolically. Returning a numeric approximation instead. 這個時候能輸出kx的數(shù)值解,所以我就比較疑惑為什么有數(shù)值解還不能賦值成功。。。 |
|
我把方程組進(jìn)行處理,整理成一個公式進(jìn)行計算,代碼如下: clear; clc; a0=8.85*1e-12; %c2/m2N ainf=12.37; %極限高頻相對介電常數(shù) 無單位 %y=pi*1e11; %衰減頻率 hz B=3; %磁場強度 T或kg/As2 %T=185; %溫度 K t=1.361*1e-6; %厚度 m e=1.6*1e-19; %單位電荷量 C me=9.11*1e-31; %電子質(zhì)量 kg m=0.033*me; %載流子質(zhì)量 kg N=8*1e23; c=3e8; %N=(5.76*1e20)*(T^1.5)*exp(-(0.13/((8.625*1e-5)*T))); %載流子濃度 m-3 此處的0.0151為KB*T KB為玻爾茲曼常數(shù)8.625e-5 eV/K,所以0.0151單位為eV wc=e*B/m; %回旋頻率 rad/s wp=sqrt(N*(e^2)/(a0*m)); %等離子頻率 rad/s %w=0:pi*2*(2*(1e12))/1000:pi*2*2*(1e12); %定義頻率范圍 rad/s %w=1.21*2*pi*1e12; dm=0.0001*2*pi*c; w=0.4*2*pi*c:dm:0.5*2*pi*c; Kx=zeros(size(w)); Ay=zeros(size(w)); for m=1:length(w); syms kx; y=(0.0382*8*(pi^3)*(c^4)*sqrt(ainf-(wp.^2)./(w(m).^2)))./((wp^2).*w(m)); axx=ainf*((1-(wp*(w(m)+1i*y)*wp))./(w(m).*(((w(m)+1i*y).^2)-((wc)^2)))); %無單位 axy=ainf*(((wp^2)*wc*1i)./(w(m).*(((w(m)+y*1i).^2)-((wc)^2)))); %無單位 azz=ainf.*((1-(wp^2))./(w(m).*(w(m)+1i*y))); %無單位 a1=real(axx); a2=imag(axx); a3=real(axy); a4=imag(axy); a5=real(azz); a6=imag(azz); kx=solve(tan(t*(((sqrt(((w(m)/c)^2)*(a1-((a4^2)/a1)))))-(kx^2)))==(a1*sqrt(((w(m)/c)^2)*(a1-((a4^2)/a1))-(kx^2))*sqrt((kx^2)-((w(m)/c)^2)))/((a1*((w(m)/c)^2))-(kx^2)-(a4*kx*sqrt((kx^2)-((w(m)/c)^2)))),kx); A=char(kx); Kx(m)=A; end 顯示: 在賦值 A( = B 中,A 和 B 中的元素數(shù)目必須相同。出錯 yanzheng (line 38) Kx(m)=A; 。。。。。 |
木蟲 (正式寫手)
MEMS小學(xué)生

| 最具人氣熱帖推薦 [查看全部] | 作者 | 回/看 | 最后發(fā)表 | |
|---|---|---|---|---|
|
[考研] 321求調(diào)劑 +3 | 何潤采123 2026-03-18 | 3/150 |
|
|---|---|---|---|---|
|
[考研] 344求調(diào)劑 +6 | knight344 2026-03-16 | 7/350 |
|
|
[考研] 085600材料與化工 +5 | 安全上岸! 2026-03-16 | 5/250 |
|
|
[考研] 311求調(diào)劑 +11 | 冬十三 2026-03-15 | 12/600 |
|
|
[考研] 085601材料工程專碩求調(diào)劑 +6 | 慕寒mio 2026-03-16 | 6/300 |
|
|
[考研] 288求調(diào)劑,一志愿華南理工大學(xué)071005 +4 | ioodiiij 2026-03-17 | 4/200 |
|
|
[考研] 0703化學(xué)調(diào)劑 +4 | pupcoco 2026-03-17 | 7/350 |
|
|
[考研] 280求調(diào)劑 +6 | 咕嚕曉曉 2026-03-18 | 7/350 |
|
|
[考研] 材料,紡織,生物(0856、0710),化學(xué)招生啦 +3 | Eember. 2026-03-17 | 9/450 |
|
|
[考研] 生物學(xué)071000 329分求調(diào)劑 +3 | 我愛生物生物愛?/a> 2026-03-17 | 3/150 |
|
|
[考研] 308求調(diào)劑 +4 | 是Lupa啊 2026-03-16 | 4/200 |
|
|
[考研] 材料專碩326求調(diào)劑 +6 | 墨煜姒莘 2026-03-15 | 7/350 |
|
|
[考研] 考研調(diào)劑 +3 | 淇ya_~ 2026-03-17 | 5/250 |
|
|
[考研] 機械專碩325,尋找調(diào)劑院校 +3 | y9999 2026-03-15 | 5/250 |
|
|
[考研] 285求調(diào)劑 +6 | ytter 2026-03-12 | 6/300 |
|
|
[考研] 288求調(diào)劑 +4 | 奇點0314 2026-03-14 | 4/200 |
|
|
[考研] 297一志愿上交085600求調(diào)劑 +5 | 指尖八千里 2026-03-14 | 5/250 |
|
|
[考研] 265求調(diào)劑 +4 | 威化餅07 2026-03-12 | 4/200 |
|
|
[考研] 297求調(diào)劑 +4 | 學(xué)海漂泊 2026-03-13 | 4/200 |
|
|
[考研] [0860]321分求調(diào)劑,ab區(qū)皆可 +4 | 寶貴熱 2026-03-13 | 4/200 |
|