Resample example from Mathworks site not working (for me).

Hi,
I am attempting to run the example code for the resample function found on the Mathworks website:
rng default
nominalFs = 48000;
f = 500;
Tx = 0:1/nominalFs:0.01;
irregTx = sort(Tx + 1e-4*rand(size(Tx)));
x = sin(2*pi*f*irregTx);
plot(irregTx,x,'. ')
desiredFs = 44100;
[y, Ty] = resample(x,irregTx,desiredFs);
plot(irregTx,x,'.-', Ty,y,'o-');
legend('Original','Resampled');
ylim([-1.2 1.2])
I get the following error when using Matlab 2014b:
"Operands to the and && operators must be convertible to logical scalar values.
Error in resample (line 63) if abs(round(p))~=p p==0"
There is surely a simple reason for this error. Does anyone have any ideas about this?

 채택된 답변

Walter Roberson
Walter Roberson 2016년 7월 1일

1 개 추천

The ability to pass a vector for the second or third parameters was introduced in R2015a, the release after yours.

댓글 수: 1

Thanks very much Walter. I suspected it might be something as simple as that. Now to decide if I should edit resample.m or update my version...

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

추가 답변 (1개)

Steven Lord
Steven Lord 2016년 7월 1일

0 개 추천

Set an error breakpoint. Run your code. When you reach the breakpoint, type dbstack. My suspicion is that the error is coming from inside a function you wrote (or downloaded, or were given) named either abs or round. If my suspicion is correct, remove or rename the version(s) of abs or round not in a MathWorks product.

댓글 수: 1

This time it was just an upgrade in functionality between versions.

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

카테고리

질문:

2016년 7월 1일

댓글:

2016년 7월 1일

Community Treasure Hunt

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

Start Hunting!

Translated by