Matlab Ass 3
Matlab Ass 3
x=0:pi/1000:2*pi;
y=sin(x);
plot(x,y);
xlabel('radians');
ylabel('sine value');
title('plot of sine curve');
2.
a=0:0.1:20;
b=4*(a.^2);
plot(a,b);
xlabel('abcissa');
ylabel('ordinate');
title(' plot of function b=4*a^2');
% since box outlines around current axes ar on by default,
% we use box off command to turn them off
box off;
3.
x=-5:0.01:10;
y=3*(x.^2)+2*x+5;
plot(x,y);
% Use the axis command to shift the axes in desired way
xlabel('x-axis');
ylabel('y-axis');
title('Plot of the function 3x^2+2x+5');
axis([-5.3 5 0 70]);
4.
fplot('x.^2+4*sin(2*x)-1',[-3,3]);
xlabel('abcissa');
ylabel('ordinate');
title('y=x^2+4sin(2x)-1');
axis([-3 3 -5 10]);
5.
x=-2:0.01:4;
f=3*(x.^3)-26*x+10;
plot(x,f,'g');
hold on;
xlabel('x-axis');
ylabel('y-axis');
fd=9*(x.^2)-26;
plot(x,fd,'--b');
hold on;
sd=18*x;
plot(x,sd,':r');
hold off;legend('3x^3-26x+10','9x^2-26','18x');
title('plot of 3x^3-26x+10 and its derivatives');
6.
If=[0 0.4 1 1.45 2 3 4 5 6];
E1=[5 30 70 110 150 215 240 250 260];
plot(If,E1,'g');
hold on;
E2=(4/5)*E1;
plot(If,E2,'--r');
hold on;
E3=(2/3)*E1;
plot(If,E3,':b');
hold off;
grid on;
legend('1500 rpm', '1200 rpm','1000 rpm');
xlabel('field current(If)');
ylabel('induced voltage(EI)');
title('EI v/s If characteristics of dc generator at different rpms');
7.
subplot(2,2,1);
I=[1 : 4];
v=4*I;
plot(I,v);
xlabel('I--->');
ylabel('v--->');
title('I v/s v ');
subplot(2,2,2);
x=[1 : 4];
r=3+zeros(1,4);%creates a row vector of magnitude 3 and length 4
y=r;
plot(x,y);
xlabel('x--->');
ylabel('y--->');
title('y v/s x ');
subplot(2,2,3);
t=0:pi/60:2*pi;
f=sin(t);
plot(t,f);
axis([0 2*pi -1 1]);
xlabel('t--->');
ylabel('sine--->');
title('t v/s sin(t) ');
subplot(2,2,4);
t=0:pi/30:2*pi;
f=cos(t);
plot(t,f);
axis([0 2*pi -1 1]);
xlabel('t--->');
ylabel('cosine--->');
title('t v/s cos(t) ');