【问题标题】:Hatching area between two symbolic curves matlab两条符号曲线matlab之间的阴影区域
【发布时间】:2013-10-10 15:27:32
【问题描述】:

我需要对符号曲线和 x 轴之间的区域进行着色。

syms x

j(1) = x^2
j(2) = x^3
j(3) = x^5
j(4) = x^6

for i = 1:4
    subplot(2,2,i);
    f(i) = ezplot(j(i),[0,6000]);
    Hatch(f(i))
end

这给了我一个错误。在查看了 matlab 文档后,我得到了类似的代码

f1 := plot::Function2d(sqrt(x), x = 0..2, Color = RGB::Black):

这甚至是matlab代码吗? “::”和“:=”是怎么回事?为什么这会引发错误? 感谢大家的帮助!

谢谢!

【问题讨论】:

  • 这是枫木代码。看看 MuPad

标签: matlab area curves


【解决方案1】:

f1 := plot::Function2d(sqrt(x), x = 0..2, Color = RGB::Black): 行用于 MuPad(符号数学工具箱)。但是,您可以使用 Matlab 的ezplot 评估没有此工具箱的符号函数。

下图

由(请参阅使您的代码工作的 cmets)给出

f{1} = 'x^2'; % declare as cell array {} of string ''
f{2} = 'x^3';
f{3} = 'x^5';
f{4} = 'x^6';

figure('Color', 'w');
for ii = 1:4                          %do not use i or j in Matlab
    subplot(2,2,ii);
    h(ii) = ezplot(f{ii},[0,6000]);   %the correct way to call ezplot
    x = get(h(ii), 'XData');          %get the x and y data
    y = get(h(ii), 'YData');
    area(x,y,'FaceColor',[.7 0 0]);   %plot the (x,y) area in red
end

【讨论】:

  • 很高兴了解字符串的元胞数组。谢谢
【解决方案2】:

mupad 下写下你的命令,然后用 Matlab 命令窗口调用它,看看这个:MatLab and MuPad

欲了解更多信息,请转到here

【讨论】: