【问题标题】:Export function from mathematica to matlab从mathematica导出函数到matlab
【发布时间】:2023-03-09 20:09:01
【问题描述】:

我正在尝试导出一个从数学中画出心脏的函数...

Export[NotebookDirectory[] <> "anim1.gif", Table[
   Plot[Sqrt[Cos[x]]*Cos[200*x] + Sqrt[Abs[x]] - 0.7*(4 - x*x)^0.01,
   {x, -2, t}, PlotStyle -> Red, Frame -> True,
   Axes -> False, PlotRange -> {{-2, 2}, {-1.7, 1.1}}]
, {t, -1.57, 2, 0.01}]]

...到matlab。 但我不知道如何在一个步骤中绘制图像,而不是制作 gif,以便稍后在图像上应用一些处理。

我试图用

创建一个符号变量
>> sim x

但是当输入试图绘图的函数时

plot([Sqrt[Cos[x]]*Cos[200*x] + Sqrt[Abs[x]] - 0.7*(4 - x*x)^0.01,))

它总是说。

Error: Unbalanced or unexpected parenthesis or bracket.

更新
我设法将其绘制为

x = [-2:0.000001:2];
>> plot ((sqrt(cos(x).*cos(200*x))+sqrt(abs(x)))-(0.7*(4-x.^2).^(0.01)))

但还是给了我下一张不完整的图片

【问题讨论】:

  • MATLAB 中给出错误的函数行是什么?您不希望 Mathematica 代码在 MATLAB 中运行,是吗?
  • MATLAB 不以这种方式使用方括号。我建议您先学习其中一个入门教程。 matlabacademy.mathworks.com

标签: matlab user-interface wolfram-mathematica linear-algebra


【解决方案1】:

定义时间向量

x=[-2:.001:2];

编写函数

 y=(sqrt(cos(x)).*cos(200*x)+sqrt(abs(x))-0.7).*(4-x.*x).^0.01;

绘制它

 plot(x,y)

Warning: Imaginary parts of complex X and/or Y arguments ignored

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多