Skip to main content

Plot a Sinusoidal Wave in Matlab

In this example, we use sinusoidal wave and plot data several different figure.



% In this example, we use sinusoidal wave and plot data several different 
% figure

t = 0:0.05:3; % sample points between 0-3
x = sin(2*pi*t); % sinusoidal value

%% Figure 1
% We have one figure screen and it has 3 figure. This is first figure
subplot(3,1,1); 
plot(t,x);
xlabel('t in second');
ylabel('x(t)');
title('sin(2\pit)');

%% Figure 2
% This is second figure, we plot x(t) value on figure 1
subplot(3,1,2);
plot(t,x,'b');
xlabel('t in sec');
ylabel('x(t)');
title('sin(2\pit)');
hold on 
plot(t,x,'ro');

%% Figure 3 
% This last figure, we plot x(t) and use stem function
subplot(3,1,3);
plot(t,x,'b');
hold on
stem(t,x,'r','fill');

Comments

Popular posts from this blog

Use offline WFDB Toolbox for MATLAB

The WFDB Toolbox for MATLAB and Octave is a collection of functions for reading, writing, and processing physiologic signals and time series in the formats used by PhysioBank databases (among others). The Toolbox is compatible with 64-bit MATLAB and GNU Octave on GNU/Linux, Mac OS X, and MS-Windows. To quick start to use offline WFDB Toolbox for Matlab http://physionet.org/physiotools/matlab/wfdb-app-matlab/wfdb-app-toolbox-0-9-6-1.zip  download this file.  Unzip file where you want. When unzip the file, mcode folder will create.  Open MATLAB.  Go where you unzip the file.  Write command line addpath(pwd) Finally write command line again savepath  You can use WFDB Toolbox offline anymore.  [tm,sig]=rdsamp('mitdb/100',1); plot(tm,sig);

ImageDatastore

ImageDatastore is a useful function and can get a collection of image files, where each individual image fits in memory, but the entire collection of images does not necessarily fit.

Using PCA on Three Dimensional Dataset

In this work, We use PCA three dimensional data.  Matlab Code % PCA Model clear all, clc , close all hold on axis equal axis([-2 2 -2 2 -2 2]) % Step 1: Get some data X = [1 2 -1 -2 0; 0.2 0 0.1 0.2 -0.4; 1.2 0.3 -1 -0.1 -0.4]'; % Step 2: Substract the mean plot3(X(:,1),X(:,2),X(:,3),'ko'); XAdjust = X-repmat(mean(X),size(X,1),1); plot3(XAdjust(:,1),XAdjust(:,2),XAdjust(:,3),'ro'); % Step 3: Calculate the covariance matrix CM = cov(X); % Step 4: Eigenvalue and Eigenvector [V D]= eig(CM); % Step 5: Choosing component f1 = V(:,1)'; f2 = V(:,2)'; f3 = V(:,3)'; F=[f1; f2; f3];