what dose [1: equations : 0] means in MATLAB?
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
Rik
2022-8-11
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.
采纳的回答
Rik
2022-8-11
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 个评论
Rik
2022-8-11
You're welcome. If this answered your question, please consider marking it as accepted answer.
更多回答(0 个)
另请参阅
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!