I wanted to save the mat files as the iteration progressed.
here is the quick solution:
it saves the mat file with number of iteration as the file name: viz: 100.mat, 200.mat etc.
This is handy when you want to compare the results of the intermediate results as you progress the iteration.
Thursday, June 11, 2009
Friday, March 20, 2009
How to show the highlighted content in the blogger post
I wanted to highlight certain texts in the blogger posts, mostly codes and others and was having difficulties.
I just looked into the source code of one of the blog and realized that this piece of code will work:
So, I can show the highlighted content in the blogger post
I just looked into the source code of one of the blog and realized that this piece of code will work:
So, I can show the highlighted content in the blogger post
Monday, March 16, 2009
Use of figure handle in Matlab
Friday, February 20, 2009
Playing with wav file in Matlab
To do:
READ THE AUDIO FILE
DISPLAY WAVEFORM
COMPUTE AND DISPLAY FREQUENCY DOMAIN AS FIGURE
% tHE VALIDITY YET TO BE TESTED...
clear all;
close all;
clc;
% import a audio
[y,Fs,nbit]=wavread('your_audio.wav');
% extract left channel only
left=y(:,1);
% calculate the time scale
Ts=1/Fs;
[nsamples,c]=size(y);
tscale=0:Ts:(nsamples-1)*Ts;
%plot left and right channel in time domain
plot(tscale,left,'r');
xlabel('Time (sec)');
ylabel('Amplitude');
%compute the FFT with the proper sampling frequency
fmax=Fs;
%how many points the FFT must be computed on?
N=nsamples;
tscale=0:Ts:(N-1)*Ts;
%N=number of FFT points:
% change it and test the different resolution
fscale=linspace(0,fmax/2,floor(N/2));
spectrum=fft(left,N);
%plot the spectrum of the signal using the appropriate
% frequency scale and module of the coefficients
%plot the magnitude
figure(2);
plot(fscale,abs((spectrum(1:length(fscale)))));
xlabel('Frequency Hz')
ylabel('Module')
READ THE AUDIO FILE
DISPLAY WAVEFORM
COMPUTE AND DISPLAY FREQUENCY DOMAIN AS FIGURE
% tHE VALIDITY YET TO BE TESTED...
clear all;
close all;
clc;
% import a audio
[y,Fs,nbit]=wavread('your_audio.wav');
% extract left channel only
left=y(:,1);
% calculate the time scale
Ts=1/Fs;
[nsamples,c]=size(y);
tscale=0:Ts:(nsamples-1)*Ts;
%plot left and right channel in time domain
plot(tscale,left,'r');
xlabel('Time (sec)');
ylabel('Amplitude');
%compute the FFT with the proper sampling frequency
fmax=Fs;
%how many points the FFT must be computed on?
N=nsamples;
tscale=0:Ts:(N-1)*Ts;
%N=number of FFT points:
% change it and test the different resolution
fscale=linspace(0,fmax/2,floor(N/2));
spectrum=fft(left,N);
%plot the spectrum of the signal using the appropriate
% frequency scale and module of the coefficients
%plot the magnitude
figure(2);
plot(fscale,abs((spectrum(1:length(fscale)))));
xlabel('Frequency Hz')
ylabel('Module')
Friday, November 28, 2008
Unique data and shuffle data problem in matlab
I had array of data with repeated values...
So, had to get non-repetitive arrays.
This could be done by :
b = unique(data);
for more one can read help unique. This is very useful function.
Moreover, I had to shuffle the data so that they are not perfectly aligned:
I found the function shuffle:
function x = shuffle(x)
%SHUFFLE Shuffle an array of values.
% x = shuffle(x) shuffles the vector x in random order.
% Since this function changes the vector x,
% it creates a copy of it.
n = length(x);
disp n
for index = 1:n
% a random number between i and n
r = index + floor((n-index+1) * rand());
% swap elements index and r
x([index r]) = x([r index]);
end
Surprisingly, it worked for whole matrix.
:)
Happy Friday!!!
Friday, November 14, 2008
Time Delayed execution of function in Javascript
I had complained about re-directing my site by some un-known ghosts.
I have created a simple function which stops it from re-direction but also gives enough time to load the contents...
http://www.howtocreate.co.uk/tutorials/javascript/timers
I have created a simple function which stops it from re-direction but also gives enough time to load the contents...
<script>Reference:
window.setTimeout('window.stop()',3000);
</script>
http://www.howtocreate.co.uk/tutorials/javascript/timers
Subscribe to:
Posts (Atom)

