what dose [1: equations : 0] means in MATLAB?
2 views (last 30 days)
Show older comments
Hello;
I currently find a code to draw signal spectrogram of the signal, I got a quite good result from the signal using their given signal, but it cannot work for my own signal, I feel so confused about one code: f=[0:nhaf -nhaf+1-odvn:-1]/N; Can I ask what is that means and why it always be an empty mitrax when I try to use it for my own signal? The code and signal of the example are shows below:
SampFreq = 1000;
t = 0: 1/ SampFreq :1;
LFM_K0 = -50.34;
LFM_f0 =100.23;
LFM_A0 = exp(-0.5*t);
Sig = LFM_A0 .*cos(2*pi*(LFM_f0*t+(LFM_K0/2)*t.^2));
SNR0 =20;
ST = stran(Sig);
imagesc(t,SampFreq,abs(ST));
axis xy;
function ST=stran(h)
% Compute S-Transform without for loops
%%% Coded by Kalyan S. Dash %%%
%%% IIT Bhubaneswar, India %%%
[~,N]=size(h); % h is a 1xN one-dimensional series
nhaf=fix(N/2);
odvn=1;
if nhaf*2==N;
odvn=0;
end
f=[0:nhaf -nhaf+1-odvn:-1]/N;
Hft=fft(h);
%Compute all frequency domain Gaussians as one matrix
invfk=[1./f(2:nhaf+1)]';
W=2*pi*repmat(f,nhaf,1).*repmat(invfk,1,N);
G=exp((-W.^2)/2); %Gaussian in freq domain
% End of frequency domain Gaussian computation
% Compute Toeplitz matrix with the shifted fft(h)
HW=toeplitz(Hft(1:nhaf+1)',Hft);
% Exclude the first row, corresponding to zero frequency
HW=[HW(2:nhaf+1,:)];
% Compute Stockwell Transform
ST=ifft(HW.*G,[],2); %Compute voice
%Add the zero freq row
st0=mean(h)*ones(1,N);
ST=[st0;ST];
end
4 Comments
Rik
on 11 Aug 2022
Let's make the sizes smaller so we can see what is happening:
signal=reshape(1:6,[],1);%create column vector
array=SomeFunctionWithImplicitExpansion(signal)
function array=SomeFunctionWithImplicitExpansion(signal)
x=signal(1:(end/2)).';%select first half and transpose
array=signal.*x;%multiply element-wise
end
As you can see, the array size goes from 6 to 18, taking up tripple the space.
Now imagine doing that with your signal. You should rethink your strategy of whatever computation you're doing to split it up.
Accepted Answer
Rik
on 11 Aug 2022
In addition to the comment from Walter:
Your question can be answered by two searches in the documentation:
doc MATLAB Operators and Special Characters
Or (since I happen to know which specific page you need):
doc colon
2 Comments
Rik
on 11 Aug 2022
You're welcome. If this answered your question, please consider marking it as accepted answer.
More Answers (0)
See Also
Categories
Find more on Time-Frequency Analysis in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!