简体   繁体   English

如何在MATLAB中的if-else语句中修复以下错误

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

So I have the following code: 所以我有以下代码:

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

Here NA = 100, NB = 80, tau_a = 2, tau_b = 4, t is an array of numbers (with a size of 21) 在这里NA = 100,NB = 80,tau_a = 2,tau_b = 4,t是一个数字数组(大小为21)

The error message I get is: "Error using *. Inner matrix dimensions must agree." 我收到的错误消息是: “使用*时出错。内部矩阵尺寸必须一致。”

How do I fix this? 我该如何解决?

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

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