Frage

I need to shade the area between symbolic curves and the x axis.

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

This gives me an error. After looking in the matlab documentation, i end up with codes like

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

Is this even matlab code? What's with the "::" and ":="? Why does this throw an error? Thanks for any help guys!

Thanks!

War es hilfreich?

Lösung

Write you command under mupad and after to call it with Matlab command window have a look to this : MatLab and MuPad

For more information go here

Andere Tipps

The line f1 := plot::Function2d(sqrt(x), x = 0..2, Color = RGB::Black): is for MuPad (Symbolic Math toolbox). However, you can evaluate the symbolic functions without this toolbox using Matlab's ezplot.

The following figure

enter image description here

is given by (please see the comments that made your code work)

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
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top