【问题标题】:Numerical integration in MATLAB GUIMATLAB GUI 中的数值积分
【发布时间】:2017-10-01 17:31:10
【问题描述】:

我想在 MATLAB GUI 中计算以下积分:

f(x) = a/(a+x^2)  

当我输入a = 1时,会出现这个结果:

a^(1/2)*atan(x/a^(1/2))

有什么问题?

这是我的代码:

 a = str2double(get(handles.anum, 'String'));     
 formula = sym(get(handles.enter_func, 'String'));       
 result = int(formula);       
 set(handles.int, 'String', char(result));    

【问题讨论】:

    标签: matlab integral


    【解决方案1】:

    我相信,handles.enter_func 中的 a 与您在 handles.anum 中定义的 a 无关。假设通用a 执行符号集成。因此,您会得到通用结果。要进行替换,您需要在集成后使用subs

    result= subs(int(formula),a,str2double(get(handles.anum , 'String')));
    

    替换会将a 替换为handles.anum 中提供的值。

    【讨论】:

      猜你喜欢
      • 2013-05-14
      • 2023-03-08
      • 1970-01-01
      • 1970-01-01
      • 2021-07-20
      • 2014-06-12
      • 1970-01-01
      • 2019-07-19
      • 2013-05-11
      相关资源
      最近更新 更多