MATLAB ,Plotting a function and its derivatives

Plotting a function and its derivatives

>> x=[-2:0.01:4];
y=3*x.^3-26*x+6;
>> yd=9*x.^2-26;
>> ydd=18*x;
>> plot(x,y,'-b',x,yd,'--r',x,ydd,':k')
Using the hold on and hold off Commands
>> x=[10:0.1:22];
y=95000./x.^2;
xd=[10:2:22];
yd=[950 640 460 340 250 180 140];
>> plot(x,y,'-','LineWidth',1.0)
>> xlabel('DISTANCE (cm)')
>> ylabel('INTENSITY (lux)')
>> title('\fontname{Arial}Light Intensity as a Function of Distance','FontSize',14)
>> axis([8 24 0 1200])
>> text(14,700,'Comparison between theory and experiment.','EdgeColor','r','LineWidth',2)
>> hold on

>> plot(xd,yd,'ro--','linewidth',1.0,'markersize',10)
Formatting a Plot Using the Plot Editor
>> semilogy(x,y)
>> semilogx(x,y)
>> loglog(x,y)
>> xd=[10:2:22];
yd=[950 640 460 340 250 180 140];
ydErr=[30 20 18 35 20 30 10]

ydErr =

    30    20    18    35    20    30    10

>> errorbar(xd,yd,ydErr)
>> xlabel('DISTANCE (cm)')
ylabel('INTENSITY (lux)')
>> yr=[1988:1994];
sle=[8 12 20 22 18 24 27];
bar(yr,sle,'r')
xlabel('Year')

ylabel('Sales (Millions)')

>> y=[58 73 73 53 50 48 56 73 73 66 69 63 74 82 84 91 93 89
91 80 59 69 56 64 63 66 64 74 63 69];
Dimensions of arrays being concatenated are not consistent.


>>  hist(y,3)


Post a Comment

1 Comments