【问题标题】:How do I fix the following error in if-else statement in MATLAB如何修复 MATLAB 中 if-else 语句中的以下错误
【发布时间】:2018-07-02 12:12:15
【问题描述】:

所以我有以下代码:

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)

我得到的错误信息是:“使用 * 时出错。内矩阵尺寸必须一致。”

我该如何解决这个问题?

【问题讨论】:

标签: matlab if-statement


【解决方案1】:

你必须使用元素乘法.*

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-11-21
    • 2018-08-30
    • 1970-01-01
    • 2015-01-26
    • 2022-09-30
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多