第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

如何在數(shù)組維度不同時(shí)評(píng)估表達(dá)式

如何在數(shù)組維度不同時(shí)評(píng)估表達(dá)式

吃雞游戲 2022-04-23 21:39:49
我想評(píng)估以下功能:inclination=np.pi/6def power(inclination,phi):    h1=1.7     h2=0.5     D = np.arange(0.5, 12.0, 0.1)    r = np.sqrt((h1-h2)**2 + D**2)    freq = 865.7     lmb = 300/freq     H = D**2/(D**2+2*h1*h2)    theta = 4*np.pi*h1*h2/(lmb*D)    q_e = H**2*(np.sin(theta))**2 + (1 - H*np.cos(theta))**2    sigma = 1.94    N_1 = np.random.normal(0,sigma,D.shape)    rnd = 10**(-N_1/10)    F = 10     power=0.2    alpha=inclination + np.arcsin((h1-h2)/r)    gain=3.136*(np.tan(alpha)*np.sin(np.pi/2*np.cos(alpha)*np.sin(phi)))**2    y=10*np.log10( 1000*(power*gain*1.622*((lmb)**2) *0.5*1) / (((4*np.pi*r)**2) *1.2*1*F)*q_e*rnd )    return y問(wèn)題是調(diào)用該函數(shù)會(huì)返回錯(cuò)誤。phi=np.arange(-np.pi/2, np.pi/2, np.pi/32)power(np.pi/6,phi)ValueError                                Traceback (most recent call last)<ipython-input-32-268e3287b75a> in <module>()----> 1 power(np.pi/6,phi)<ipython-input-30-4b89d23682ce> in power(inclination, phi)     19      20     alpha=inclination + np.arcsin((h1-h2)/r)---> 21     gain=3.136*(np.tan(alpha)*np.sin(np.pi/2*np.cos(alpha)*np.sin(phi)))**2     22     print(gain)     23     y=10*np.log10( 1000*(power*gain*1.622*((lmb)**2) *0.5*1) / (((4*np.pi*r)**2) *1.2*1*F)*q_e*rnd )ValueError: operands could not be broadcast together with shapes (115,) (32,) 可能是因?yàn)樗г筭ain符合矩陣alpha和phi不同維度的操作。問(wèn)題是我想使用不同的矩陣維度,并保存一個(gè)txt文件,其中第一列是r第二列phi,第三 列是y.
查看完整描述

1 回答

?
白衣染霜花

TA貢獻(xiàn)1796條經(jīng)驗(yàn) 獲得超10個(gè)贊

您需要向其中一個(gè)數(shù)組添加維度以啟用廣播


>>> alpha = np.ones(115, dtype=np.uint8)

>>> phi = np.ones(32, dtype=np.uint8)


>>> c = alpha[:,None] * phi

>>> alpha.shape, alpha[:,None].shape, phi.shape, c.shape

((115,), (115, 1), (32,), (115, 32))

假設(shè)alpha.shape是(115,):`


>>> gain=3.136*(np.tan(alpha[:,None])*np.sin(np.pi/2*np.cos(alpha[:,None])*np.sin(phi)))**2

>>> gain.shape

(115, 32)


查看完整回答
反對(duì) 回復(fù) 2022-04-23
  • 1 回答
  • 0 關(guān)注
  • 113 瀏覽
慕課專(zhuān)欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)