簡體   English   中英

如何在MATLAB中的if-else語句中修復以下錯誤

[英]How do I fix the following error in if-else statement in MATLAB

所以我有以下代碼:

if tau_a == tau_b
    ana_nb = NB * exp(-t/tau_a) + t * (NA/tau_a) * exp(-(t/tau_a))
else
    ana_nb = NB * exp(-t/tau_b) + NA/((tau_a/tau_b)-1) * (exp(-t/tau_a) - exp(-t/tau_b))
end

在這里NA = 100,NB = 80,tau_a = 2,tau_b = 4,t是一個數字數組(大小為21)

我收到的錯誤消息是: “使用*時出錯。內部矩陣尺寸必須一致。”

我該如何解決?

您將不得不使用元素明智的乘法.*

ana_nb = NB .* exp(-t/tau_a) + t .* (NA/tau_a) .* exp(-(t/tau_a))

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM