1. Memasang aplikasi Waijung dan Matlab & Simulink 2. Menjalankan aplikasi Waijung dan Matlab & Simulink 3. Memratikkan example-example yang tersemat dalam artikel
ALAT DAN BAHAN
Beberapa komponen yang digunakan untuk melaksanakan
praktikum: 1. Laptop/PC 2. Mouse 3. Matlab
METODE/LANGKAH KERJA
2.1 Some Examples
1. Example 1: Generating a Sine Wave using MATLAB This example shows how sine wave and cosine wave can be generated. Furthermore they are plotted against time to observe their phase difference. In order to do so, we need to know the two important things. • What should be the center frequency of the signal? • What should be the sampling frequency of the signal?
2. Example 2: Discrete Fourier Transform and Power Spectral
Density Calculations % Show the use of the FFT function for spectral analysis. % Create signal at 50 Hz and 120 Hz t = 0:.001:.25; x1 = sin(2*pi*50*t); x2 = sin(2*pi*120*t); x = x1 + x2; % Add some random noise y = x + 2*randn(size(t)); subplot(611),plot(x1), title('Sine wave at 50 Hz') subplot(612),plot(x2), title('Sine wave at 120 Hz') subplot(613),plot(x), title('Sine wave at 50 Hz + 120 Hz') subplot(614),plot(y), title('Noisy time domain signal') % Finding the discrete Fourier transform Y = fft(y,256); % Compute the power spectral density Pyy = Y.*conj(Y)/256; f = 1000/256*(0:127); subplot(615),plot(y), title('Noisy time domain signal') subplot(616), plot(f,Pyy(1:128)), title('Power spectral density') xlabel('Frequency (Hz)')
3. Example 3: Representing Data in Plots
clear all, close all % Scatter Plot figure; load count.dat scatter(count(:,1),count(:,2),'r*') xlabel('Number of Cars on Street A'); ylabel('Number of Cars on Street B'); title('Scatter Plot') % Stem Plot figure; x = 0:0.1:4; y = sin(x.^2).*exp(-x); stem(x,y) title('Stem Plot') % Polar Plot figure; t=0:0.01:2*pi; polar(t,abs(sin(2*t).*cos(2*t))); title('Polar Plot') % Errorbar Plot figure; x=-2:0.1:2; y=erf(x); e = rand(size(x))/10; errorbar(x,y,e); title('Errorbar Plot') % Stairstep Plot figure; x=0:0.25:10; stairs(x,sin(x)); title('Stairstep Plot') % Bar Plot figure; x = -2.9:0.2:2.9; bar(x,exp(-x.*x)); title('Bar Plot') % Line Plot figure; x=0:0.05:5; y=sin(x.^2); plot(x,y); xlabel('Time'); ylabel('Amplitude') title('Line Plot') 4. Example 4: Drawing a Heart close all; clear all; clc v = -1.5:.02:1.5; [x,y,z] = meshgrid(v,v,v); w = (2*x.^2+y.^2+z.^2-1).^3-(1/10)*x.^2.*z.^3- y.^2.*z.^3; hp = patch(isosurface(w,0)); set(hp,'facecolor','r','edgecolor','none') light; lighting phong; view(99,18)
3.2 Examples using Simulink
1. Example 1: Creating and Observing a Sine-wave We start with the simplest case. Open a new model. Save a model with a legit name. Now a reader should think before going further, what blocks are required in order to create and sine wave and see the created sine wave. The answer is very simple. Two things i.e. something which can generate a sine wave and something which is like a oscilloscope in the labs to see it. We search for these two items in ‘Simulink Library Browser’. When right choice of component is found, simply drag that block to the new model created. 2. Example 2: Integrating a sine wave Now, we can move forward quickly. For the next example, we require the following blocks. • Sine wave • Integrator • Scope • Gain • Bus creator These blocks are arranged in the following order as shown 3. Example 3: Inverted Pendulum on a cart go to Simulink, click on “help” right away and search for “inverted pendulum with animation”. Click the “open model” button.
HASIL PRAKTIKUM
2.1 Some Examples
1. Example 1: Generating a Sine Wave using MATLAB Sinyal sinusoidal dengan frekuensi FM=600Hz. Untuk mewujudkannya sebagai sinyal berulang saat plotting, laju pengambilan sampel fs = 500KHz. fs= 500e3; f= 600; nCyl=5; t=0:1/fs:nCyl*1/f; x=sin(2*pi*f*t); plot(t,x) title ('Continuous sinusoidal signal') xlabel('Time(s)'); ylabel('Amplitude');
2. Example 2: Discrete Fourier Transform and Power Spectral
Density Calculations % Show the use of the FFT function for spectral analysis. % Create signal at 50 Hz and 120 Hz t = 0:.001:.25; x1 = sin(2*pi*50*t); x2 = sin(2*pi*120*t); x = x1 + x2; % Add some random noise y = x + 2*randn(size(t)); subplot(611),plot(x1), title('Sine wave at 50 Hz') subplot(612),plot(x2), title('Sine wave at 120 Hz') subplot(613),plot(x), title('Sine wave at 50 Hz + 120 Hz') subplot(614),plot(y), title('Noisy time domain signal') % Finding the discrete Fourier transform Y = fft(y,256); % Compute the power spectral density Pyy = Y.*conj(Y)/256; f = 1000/256*(0:127); subplot(615),plot(y), title('Noisy time domain signal') subplot(616), plot(f,Pyy(1:128)), title('Power spectral density') xlabel('Frequency (Hz)') 3. Example 3: Representing Data in Plots clear all, close all % Scatter Plot figure; load count.dat scatter(count(:,1),count(:,2),'r*') xlabel('Number of Cars on Street A'); ylabel('Number of Cars on Street B'); title('Scatter Plot') % Stem Plot figure; x = 0:0.1:4; y = sin(x.^2).*exp(-x); stem(x,y) title('Stem Plot') % Polar Plot figure; t=0:0.01:2*pi; polar(t,abs(sin(2*t).*cos(2*t))); title('Polar Plot') % Errorbar Plot figure; x=-2:0.1:2; y=erf(x); e = rand(size(x))/10; errorbar(x,y,e); title('Errorbar Plot') % Stairstep Plot figure; x=0:0.25:10; stairs(x,sin(x)); title('Stairstep Plot') % Bar Plot figure; x = -2.9:0.2:2.9; bar(x,exp(-x.*x)); title('Bar Plot') % Line Plot figure; x=0:0.05:5; y=sin(x.^2); plot(x,y); xlabel('Time'); ylabel('Amplitude') title('Line Plot') 4. Example 4: Drawing a Heart close all; clear all; clc v = -1.5:.02:1.5; [x,y,z] = meshgrid(v,v,v); w = (2*x.^2+y.^2+z.^2-1).^3-(1/10)*x.^2.*z.^3- y.^2.*z.^3; hp = patch(isosurface(w,0)); set(hp,'facecolor','b','edgecolor','none') light; lighting phong; view(99,18)
3.2 Examples using Simulink
1. Example 1: Creating and Observing a Sine-wave 2. Example 2: Integrating a sine wave
3. Example 3: Inverted Pendulum on a cart
ANALISIS HASIL PRAKTIKUM
2.1 Some Examples
1. Example 1: Generating a Sine Wave using MATLAB Jika frekuensi sampling terlalu rendah maka kita tidak akan bisa mendapatkan gelombang sinusoidal yang bagus. Jika frekuensi sampling terlalu tinggi maka gelombang akan menjadi sangat halus tetapi waktu komputasi akan meningkat. Frekuensi tengah sebesar 500KHz dan frekuensi sampling sebesar 600 Hz. 2. Example 2: Discrete Fourier Transform and Power Spectral Density Calculations Saluran dapat berupa kabel (kabel tembaga, twisted pair, serat optik) atau nirkabel (udara, vakum). Saluran adalah titik di mana sebagian besar kebisingan diperkenalkan dalam sinyal yang ditransmisikan. Kita dapat mengamati bahwa bahkan setelah penambahan noise, FFT memungkinkan kita memulihkan kembali frekuensi tengah dari dua sinyal. Di bagian bawah, dapat diamati dua puncak masing-masing pada 50Hz dan 120Hz yang sama dengan frekuensi sinyal yang kita pilih di awal. 3. Example 3: Representing Data in Plots Grafik adalah salah satu cara untuk merepresentasikan data besar yang dapat menghasilkan informasi yang bermakna. Pembaca dapat menemukan cara bagaimana suatu data dapat direpresentasikan menggunakan MATLAB. Dalam contoh 3 ini, data yang sama direpresentasikan dalam tujuh cara berbeda yaitu scatter, stem, polar, error-bar, stair-step, bar dan line plot. 4. Example 4: Drawing a Heart MATLAB tidak hanya untuk melakukan penelitian serius tetapi sesuatu yang romantic, juga dapat dibuat dengan menggunakan beberapa baris MATLAB. Berikut adalah contoh 4 merupakan contoh kode untuk membuat hati.
3.2 Examples using Simulink
1. Example 1: Creating and Observing a Sine-wave Blok yang diperlukan untuk membuat dan melihat gelombang sinus, yaitu sesuatu yang dapat menghasilkan dan melihat gelombang sinus yang dapat ditemukan di 'Simulink Library Browser'. Tombol 'play' atau Ctrl + T simulink akan mulai mengkompilasi. Klik dua kali pada tombol scope akan muncul keluaran yang ditunjukkan pada gambar. 2. Example 2: Integrating a sine wave Gelombang sinus yang dirancang di atas ke dalam model Simulink, dapat dibuat dan dilihat cara kerjanya sebagai pencarian langsung, dengan interpolasi linier, dan dengan perkiraan CORDIC. Model ini membandingkan output tabel floating point dengan fungsi sin(). Seperti yang diharapkan dari perhitungan THD, interpolasi linier memiliki kesalahan yang lebih rendah daripada pencarian tabel langsung dibandingkan dengan fungsi sin(). Perkiraan CORDIC menunjukkan margin kesalahan yang lebih rendah jika dibandingkan dengan metode interpolasi linier. Margin ini tergantung pada jumlah iterasi saat menghitung perkiraan dosa CORDIC. Anda biasanya dapat mencapai akurasi yang lebih besar dengan meningkatkan jumlah iterasi (sesuai dengan waktu komputasi yang lebih lama). Perkiraan CORDIC menghilangkan kebutuhan akan pengganda eksplisit. Ini digunakan ketika pengganda kurang efisien atau tidak ada dalam perangkat keras.
3. Example 3: Inverted Pendulum on a cart
Model pada example 3 didapatkan melalui menu “help” yang berada di Simulink.
Sistem pendulum terbalik adalah contoh yang biasa
ditemukan dalam buku teks sistem kontrol dan literatur penelitian. Popularitasnya sebagian berasal dari fakta bahwa itu tidak stabil tanpa kontrol, yaitu, pendulum hanya akan jatuh jika gerobak tidak dipindahkan untuk menyeimbangkannya. Selain itu, dinamika sistem bersifat nonlinier. Tujuan dari sistem kontrol adalah untuk menyeimbangkan pendulum terbalik dengan menerapkan gaya ke gerobak tempat pendulum terpasang. KESIMPULAN
Waijung adalah tambahan untuk MATLAB/Simulink blockset.
Mendukung pemberdayaan siswa untuk membuat algoritma yang lebih kompleks dalam waktu yang lebih singkat. Ini akan lebih menguntungkan bagi industri dalam hal produk yang lebih baik, lebih banyak nilai, dan lebih banyak bisnis. Dengan ambisi membuat proses yang rumit dan sulit dipahami menjadi sederhana, saat ini milik kami perusahaan terutama berfokus pada (tetapi tidak terbatas pada) sinyal digital dan pemrosesan gambar, jaringan sistem pemantauan dan pengendalian.