All Progs

You might also like

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 3

prog pie chart

******************
X = [19.3
34.2
61.4
50.5
29.4

22.1
70.3
82.9
54.9
36.3

51.6;
82.4;
90.8;
59.1;
47.0];

explode = zeros(size(x));
[c,offset] = max(x);
explode(offset) = 1;
h = pie(x,explode);
colormap summer
textObjs = findobj(h,'Type','text');
oldStr = get(textObjs,{'String'});
val = get(textObjs,{'Extent'});
oldExt = cat(1,val{:});
Names = {'Product X: ';'Product Y: ';'Product Z: '};
newStr = strcat(Names,oldStr);
set(textObjs,{'String'},newStr)
val1 = get(textObjs, {'Extent'});
newExt = cat(1, val1{:});
offset = sign(oldExt(:,1)).*(newExt(:,3)-oldExt(:,3))/2;
pos = get(textObjs, {'Position'});
textPos = cat(1, pos{:});
textPos(:,1) = textPos(:,1)+offset;
set(textObjs,{'Position'},num2cell(textPos,[3,2]))
--------------*****----------------------------------------SINE COS (30 must be taken input) ## Attention MOIZ (2 progs here) if u do plot
(x,y) it wl only plot sine
## if u do plot (x,z) it wl only plot cos
=======================######====================
x = linspace(0,2*pi,30);
y = sin(x);
z = cos(x);
plot(x,y,x,z)
title('Figure: Sine and Cosine Wave')
===============########==================================

Fourier plot (Vm, T0 should be taken input) it wl plot only five components
-------------------*****----------------------syms an bn n v t Cn C0
%initialization

T0 = 0.4;
f0 = 1/T0;
Vm = 2;
n = [1:5]
v = Vm*cos(2*pi*f0*t)

%Actual signal

%a0,bn and an formulas for periodic signals


a0 = (1/T0)*int(v,t,-0.1,0.1)
bn = int ( (2/T0)* v * sin(n*2*pi*f0*t) , t , -0.1,0.1 )
an = int ( (2/T0)* v * cos(n*2*pi*f0*t) , t , -0.1,0.1 )
C0 = a0
Cn = ( (an.^2) + (bn.^2) ).^0.5
Cn_values = [eval(C0), eval(Cn)]
plot([0,n],Cn_values,'r')
hold on
stem([0,n],Cn_values,'k')
hold off
%Another plot with negative values indicating the phases
an_values = [eval(a0), eval(an)]
figure
plot([0,n],an_values,'r')
hold on
stem([0,n],an_values,'k')
hold off
%==== Try different n,f0,Vm values of this example.====
clear all
---------------********----------------------------------------EXPONENTIAL PLOT ( make like dat -10 in the exp should be taken input)
#######################
t = 0:0.1:1;
x = exp(-10.*t);
% two array t and x, each of size 1*11 are generated.
plot(t,x)
figure
plot(t,x,'ro')
% previous fig. is overwritten by this plot which shows
%discrete points in the form of red os.
clc
% clears the screen
figure % create new figure window
stem(t,x) %discrete plot is generated
###################################

UNIT STEP FUNCTION ( the values in y shold be taken by input 13 values, and zero
s(1,18) remains as it is))
-----------------#########---------------------

clf;
n = -10:20;
or from -10 to 20
u=[zeros(1,10) 1 ones(1,20)];
uence
y=[3 2 4 9 7 8 10 11 12 5 8 10 12 zeros(1,18)];
r=u.*y;
stem(n,r);
xlabel('time independent n');
ylabel('Amplitude');
title('Unit Step Sequence');
axis([-10 20 0 15]);

%generate a vect
%generate the unit step seq

---------------------######-------------------IF u count there wil b six porgs. 2 (sine cos progs), fourier, exp, unit step, p
ie chart

You might also like