Please find the attachment data.mat
figure(1)
plot(exp_f2,exp_t2,'ro')
ylabel('Unifrom Time Step 2.5ms');xlabel('Hz');title('Mode 2 Exp data,fs=400Hz')
Here I have uniform time step 2.5ms on my y axis. But I need an uniform frequency step on my x axis like
f2_interp=linspace(exp_f2(1),exp_f2(end),400);
How can I interpolate or resample it? Thanks!

 채택된 답변

KSSV
KSSV 2018년 8월 21일

0 개 추천

% interpolation
ti=linspace(min(exp_t2),max(exp_t2),400);
yi = interp1(exp_t2,exp_f2,ti) ;
plot(yi,ti)

댓글 수: 7

Rik
Rik 2018년 8월 22일
Please don't use flags to reply to comments.
"Hi KSSV, this will give me a non uniform frequency step. "diff(yi)" in your code has to return an unfirom freq step."
You need to choose: either ti will be uniformly sampled, or yi will have uniform steps, or you can only have the function y=x. Which of these three do you want?
Hi, I would like to have my exp_f2 out of the attached data.mat to be uniformly sampled.
f2=linspace(min(exp_f2),max(exp_f2),numel(exp_t2));
t2=interp1(exp_f2,exp_t2,f2,'pchip');
is not working. May I ask how to fix it? Thank
Rik
Rik 2018년 8월 22일
exp_f2 is not an output of that code. Which of the 3 options I described do you want? In your code f2 is uniform, but t2 is probably not.
Tsuwei Tan
Tsuwei Tan 2018년 8월 22일
There is an attached data.mat file which contains exp_f2, can you download it?
Rik
Rik 2018년 8월 22일
Sure, I can download that .mat file and load the variables, but that doesn't tell me what you want. I can't help you find a solution if you don't explain what you want. I've explained the three options. Pick one, or explain better what you want.
In your code, you make the exp_t2 which is already uniform step to be uniform again:
ti=linspace(min(exp_t2),max(exp_t2),400);
What I need is to make exp_f2 to be uniform:
f2=linspace(min(exp_f2),max(exp_f2),numel(exp_t2));
The output of "interp1" command doesn't have to be uniform, thanks!
Rik
Rik 2018년 8월 22일
Now I'm really confused. You want to make a variable uniform that is already uniform? And if you already have the code to do that, what is your question? And to what code are you referring to as "your code"? I haven't posted any code in this thread, only you and KSSV have.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

제품

릴리스

R2018a

질문:

2018년 8월 21일

댓글:

Rik
2018년 8월 22일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by