We have moved to @ Placement Papers Hub !! Visit our new website here for more..

Matlab structure program and difference program and degree program

1 structure program

clc;
clear all;
close all;
%s=struct('name','manoj','age',25,'empid',16133);

s=struct('name',{'manoj','manu'},'age',{25,24},'empid',{16133,16179})

s.name
s.age
s.empid

% also structure can be initialized by other method like
patient.name='man';   % here patient is structure and name is a field
patient.age=25;
patient.bill=2000;
 
%similarly for patient 2(for array of structure)
patient(2).name='mani';   % here patient is structure and name is a field
patient(2).age=24;
patient(2).bill=3000;

patient(1)   %to display patient 1 record
patient(2)   %to display patient 2 record    similarly patient(2).name, patient(1).bill   we can use

%for deleting a field in structure we use [] or rmfield

patient(2)=[]   %patient2 record will be deleted
  1. difference program
clc;
clear all;
close all;
a=dsolve('Dy=2*y+t');
disp(a);

b=dsolve('D2y=2*y+t','y(0)=1,Dy(1)=1');
disp(b);
  1. degree program
clc;
clear all;
close all;
x=[-2:.01:4];
y=3*x.^3-26*x+6;
yd=9*x.^2-26;
ydd=18*x;
plot(x,y,'-b')

line(x,yd,'color','r')
line(x,ydd,'color','g');
title('Differentiation graph','color','r','fontsize',20);
text(-1,37,'\leftarrowNo derivative','color','b','edgecolor','k','linewidth',3);
text(.5,-30,'\uparrowFirst derivative','color','r','edgecolor','k','linewidth',3);
text(1,-20,'\leftarrow2nd derivative','color','g','edgecolor','k','linewidth',3);
legend('Equation','first derivative','2nd derivative',0);
xlabel('Time','color','m');

ylabel('Amplitude','color','m');