Wednesday, 28 November 2018

Adding text, customized axes, and legends in R

Adding text, customized axes, and legends R
> par(font.lab=3, cex.lab=1.5, font.main=4, cex.main=2)
> dose <- c(20, 30, 40, 45, 60)
> drugA <- c(16, 20, 27, 40, 60)
> drugB <- c(15, 18, 25, 31, 40)
> opar <- par(no.readonly=TRUE)
> par(pin=c(2, 3))
> par(lwd=2, cex=1.5)
> par(cex.axis=.75, font.axis=3)
> plot(dose, drugA, type="b", pch=19, lty=2, col="red")
> plot(dose, drugB, type="b", pch=23, lty=6, col="blue", bg="green")
> plot(dose, drugA, type="b",
+      col="red", lty=4, pch=5, lwd=2,
+      main="Clinical Trials for Drug A",
+      sub="This is hypothetical data",
+      xlab="Dosage", ylab="Drug Response",
+      xlim=c(0, 60), ylim=c(0, 70))

Saturday, 10 November 2018

POLAR PLOTS IN MATLAB

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)


Friday, 9 November 2018

THE PLOT,FPLOT,FUNCTION COMMAND MATLAB

THE PLOT COMMAND
If a vector x has the elements 1, 2, 3, 5, 7, 7.5, 8, 10, and a vector y has the elements 2, 6.5, 7, 7, 5.5, 4, 6, 8, a simple plot of y versus x can be created by typing the following in the Command Window:

>>  x=[1 2 3 5 7 7.5 8 10];
y=[2 6.5 7 7 5.5 4 6 8];
plot(x,y)


>> yr=[1988:1:1994];
>> sle=[8 12 20 22 18 24 27];
>>  plot(yr,sle,'--r*','linewidth',2,'markersize',12)



The plot of a Function
>> x=[-2:0.01:4];
>> y=3.5.^(-0.5*x).*cos(6*x);
>> plot(x,y)
THE fplot COMMAND
fplot('x^2+4*sin(2*x)-1',[-3 3])



Thursday, 8 November 2018

ADALINE time series prediction

ADALINE time series prediction
 [p1,p2] = meshgrid(-10:.25:10);
z = feval(func, [p1(:) p2(:)]*w'+b );
z = reshape(z,length(p1),length(p2));
plot3(p1,p2,z)
grid on
xlabel('Input 1')
ylabel('Input 2')
zlabel('Neuron output')
Warning: MATLAB has disabled some advanced graphics rendering features by switching to
software OpenGL. For more information, click here.
>> K = 30;
% define classes
q = .6; % offset of classes
>> A = [rand(1,K)-q; rand(1,K)+q];
B = [rand(1,K)+q; rand(1,K)+q];
C = [rand(1,K)+q; rand(1,K)-q];
D = [rand(1,K)-q; rand(1,K)-q];
>> plot(A(1,:),A(2,:),'bs')
>> hold on
grid on
plot(B(1,:),B(2,:),'r+')
plot(C(1,:),C(2,:),'go')
plot(D(1,:),D(2,:),'m*')
>> text(.5-q,.5+2*q,'Class A')
text(.5+q,.5+2*q,'Class B')
text(.5+q,.5-2*q,'Class C')
text(.5-q,.5-2*q,'Class D')
>> a = [0 1]';
b = [1 1]';
c = [1 0]';
d = [0 0]';
>> % a = [0 1]';
% b = [1 1]';
% d = [1 0]';
% c = [0 1]';
>> P = [A B C D];
>> T = [repmat(a,1,length(A)) repmat(b,1,length(B)) ...
 repmat(c,1,length(C)) repmat(d,1,length(D)) ];
%plotpv(P,T);
>> net = perceptron;
>> E = 1;
net.adaptParam.passes = 1;
linehandle = plotpc(net.IW{1},net.b{1});
n = 0;
>> while (sse(E) & n<1000)
 n = n+1;
 [net,Y,E] = adapt(net,P,T);
 linehandle = plotpc(net.IW{1},net.b{1},linehandle);
 drawnow;
end
>> view(net);
>> p = [0.7; 1.2]
y = net(p)

p =

    0.7000
    1.2000


y =

     1
     1

>> dt = 0.01; % time step [seconds]
t1 = 0 : dt : 3; % first time vector [seconds]
t2 = 3+dt : dt : 6; % second time vector [seconds]
t = [t1 t2];
>> y = [sin(4.1*pi*t1) .8*sin(8.3*pi*t2)];
>> plot(t,y,'.-')
>> xlabel('Time [sec]');
>> ylabel('Target Signal');
>> grid on
ylim([-1.2 1.2])
>> p = con2seq(y);
>> inputDelays = 1:5; % delayed inputs to be used
learning_rate = 0.2;
>> net = linearlayer(inputDelays,learning_rate);
>> [net,Y,E] = adapt(net,p,p);
>> view(net)
>> disp('Weights and bias of the ADALINE after adaptation')
net.IW{1}
net.b{1}
Weights and bias of the ADALINE after adaptation

ans =

    0.7179    0.4229    0.1552   -0.1203   -0.4

>> Y = seq2con(Y); Y = Y{1};
E = seq2con(E); E = E{1};
>> subplot(211)
plot(t,y,'b', t,Y,'r--');
legend('Original','Prediction')
grid on
>> xlabel('Time [sec]');
ylabel('Target Signal');
ylim([-1.2 1.2])
>> subplot(212)
plot(t,E,'g');
grid on
>> legend('Prediction error')
xlabel('Time [sec]');
ylabel('Error');
ylim([-1.2 1.2])


Wednesday, 7 November 2018

How to verify trigonometric identity -R

A trigonometric identity is given by: cos^2(x/2)=(tanx+sinx)/2tanx

writing trigonometric equations,class 11 maths chapter 3,sineskwela,pinoy teacher,tagalog,math tutor,trigomometry,trigonometric function and their values at allied angles,trigonometry for class 11 maths,arvind academy,function (literature subject),trigonometry in hindi,trigonometry for jee mains,trigonometry for jee advanced,shortcut techniques of trigonometry



Verify that the identity is correct by calculating each side of the equation, substituting.x=pi/2
sol.
>> x=pi/5;
LHS=cos(x/2)^2
LHS =
 0.9045
RHS=(tan(x)+sin(x))/(2*tan(x))
RHS =

 0.9045

General procedure to sample from continuous distributions

A general procedure to sample from continuous distributions
>> alpha=5;N=1000;
parCDF=@(x,alpha) 1-(1+x).^-alpha;
parICDF=@(x,alpha) (1-x).^(-1/alpha) - 1
Xi=linspace(0,1,N);
plot(Xi, parCDF(Xi,alpha) )
hold on
plot(parICDF(Xi,alpha), Xi, ’r--’)
axis([0 3 0 1]);

parICDF =

  function_handle with value:

    @(x,alpha)(1-x).^(-1/alpha)-1

Tuesday, 6 November 2018

The convex hull of a data set in n-dimensional space

The convex hull of a data set in n-dimensional space 

>> figure, hold on
d = [1 2 3 1]; % Index into C column.
for i = 1:size(C,1) % Draw each triangle.
j= C(i,d); % Get the ith C to make a patch.
 h(i)=patch(X(j,1),X(j,2),X(j,3),i,'FaceAlpha',0.9);
end % 'FaceAlpha' is used to make it transparent.
hold off
view(3), axis equal, axis off
camorbit(90,-5); % To view it from another angle
title('Convex hull of a cube')
Undefined function or variable 'C'.

>> d = [-1 1];
[x,y,z] = meshgrid(d,d,d);
X = [x(:),y(:),z(:)]; % 8 corner points of a cube
C = convhulln(X)

C =

     4     2     1
     3     4     1
     7     3     1
     5     7     1
     7     4     3
     4     7     8
     2     6     1
     6     5     1
     4     6     2
     6     4     8
     6     7     5
     7     6     8

>>  figure, hold on
d = [1 2 3 1]; % Index into C column.
for i = 1:size(C,1) % Draw each triangle.
j= C(i,d); % Get the ith C to make a patch.
 h(i)=patch(X(j,1),X(j,2),X(j,3),i,'FaceAlpha',0.9);
end % 'FaceAlpha' is used to make it transparent.
hold off
view(3), axis equal, axis off
camorbit(90,-5); % To view it from another angle
title('Convex hull of a cube'

Animation is a method in which picturese Mathematics

It is Associate in Nursing knowledge domain approach fuelled by refined arithmetic, mathematical modeling and modelgalvanized by observations created on complicated systems within the most various fields together with meteorology, climate analysis, ecology, economics, physics, embryology, laptop networks and plenty of additional




Friday, 2 November 2018

Electric potential of two point charges

The electric potential of two point charges.

electric potential energy of two point charges,test,chandil,edupoint,arvind academy,electric potential & capacitance,university,electrostatic,student,exam,sample,electric potential in hindi,point,campus,students,educational,study,energy,difference,electric potential and potential difference,arijit daripa,electric potential class 12,energy stored in capacitor,इलेक्ट्रिक पोटेंशियल


 The electric potential V around a charged particle is given by where is the permittivity constant, q is the magnitude of the charge in coulombs, and r is the distance from the particle in meters.
V=1/4pie0 (q/r)


>> eps0=8.85e-12; q1=2e-10; q2=3e-10;
k=1/(4*pi*eps0);
x=-0.2:0.01:0.2;
y=-0.2:0.01:0.2;
[X,Y]=meshgrid(x,y);
>> r1=sqrt((X+0.25).^2+Y.^2);
r2=sqrt((X-0.25).^2+Y.^2);
V=k*(q1./r1+q2./r2);
mesh(X,Y,V)
xlabel('x (m)'); ylabel('y (m)'); zlabel('V (V)')


Thursday, 1 November 2018

Define Target Signals input and output data

Define input and output data

what is defferint of data flow and control flow,sensing and input,analog output,target position,export data,import data,vector signal generator,rf analog signal generator,agn signal relays,signal generator,sensor signals,what is data flow testing,what is data flow diagram,ginput,input error,test and measurement systems,data flow and control flow,perbandingan data frequency respon,signal relays


>> dt = 0.01; % time step [seconds]
t1 = 0 : dt : 3; % first time vector [seconds]
t2 = 3+dt : dt : 6; % second time vector [seconds]
t = [t1 t2]; % complete time vector [seconds]
% define signal
y = [sin(4.1*pi*t1) .8*sin(8.3*pi*t2)];
% plot signal
plot(t,y,'.-')
xlabel('Time [sec]');
ylabel('Target Signal');
grid on
ylim([-1.2 1.2])

Latin Cubes

What is Latin Cubes? The practical applications of Latin crops and related designs are factorial experiment.factorial experiments for me...