Tuesday, April 20, 2010

Test


\int_{-\infty}^{\infty}e^{-x^{2}}\;dx=\sqrt{\pi}


Just trying my jsTeXrender

Plotting Discontinuous Graph

From one of the problem in here :









I've got some clue from here. So, here is my solution :
t = -5:0.01:5;     % total range of the graph

q1 = t<-4;            % range 1
q2 = t>=-4 & t<3;     % range 2 
q3 = t>=3;            % range 3

y = zeros(size(t));    % initialization

y(q1) = 0;             % curve 1
y(q2) = t(q2) + 2;     % curve 2
y(q3) = t(q3) - 2;     % curve 3

plot(t,y); axis([-5 5 -4 7])

And here is the graph :
















Okay. The x(t) above is quite simple. How if it is --in example-- an polynomial equation? The concept remains the same. But, don't forget to use the dot operator, because we will power each of array member.

Monday, April 19, 2010

Plotting Continuous Signal #1 - Unit Step Function

x(t) = 4u(t) + 2sin(3t)




Matlab's inline function is convenient for creating unit step function.

Code :
t = -pi:0.01:pi;
u = inline('t >= 0');  
y = 4*u(t) + 2*sin(3*t);

plot(t,y,'r');grid on;
axis([-4 4 -3 7]);
xlabel('t'); ylabel('x(t)');
title('x(t) = 4u(t) + 2sin(3t)')

(From exercise 1C, chapter 1, book Fundamentals of Signals and Systems, 2nd ed. (Edward W. Kanen, Bonnie S. Heck))

Sunday, April 18, 2010

Demonstrating Convolution in Matlab

This simulation demonstrates convolution between two signals.
Graph 1 -> signal A
Graph 2 -> signal B
Graph 3 -> convolution of A and B




The code :


clear all;

x = [0 0 -1 2 3 -2 0 1 0 0];
dtx = -2:7;     % non-zero range of x
y = [1 -1 2 4];
dty = 8:11;     % non-zero range of y
z = conv(x,y);
dtz = 6:18;     % non-zero range of z

% plotting
dt = -2:20;
subplot(311);stem(dt,[x zeros(size(8:20))]);
title('Signal A');

subplot(312);stem(dt,[zeros(size(-2:7)) ...
y zeros(size(12:20))]);
title('Signal B');

subplot(313);stem(dt,[zeros(size(-2:5)) ...
z zeros(size(19:20))]);
title('A * B');

I use the example from here, at page 3.

Preface - Mukadimah

Hi.
This blog is all about my notes of everything that I currently learn. I'm expecting that I'll fill it out with Matlab and network programming stuff.

Hopefully I'm able to resist against my biggest enemy : laziness
Just wish me luck :D

---

Hai.
Blog ini berisi catatan saya selama belajar Matlab dan network programming. Semoga saja saya mampu bertahan lama dalam mengisi blog ini. Saya punya banyak blog. Dan dari kesemuanya itu, tak ada satupun yang terpelihara dengan baik :D Semoga blog ini tidak bernasib sama :-)

Yang pasti, blog ini akan sangat berguna bagi saya. Dan saya harap, blog ini juga memberikan efek yang sama juga bagi Anda.

makasih.