resample gives dimension error
Ältere Kommentare anzeigen
When I use the resample function, I get a dimension error. Here is the example used in the MATLAB help file, with the output:
fs1 = 10; % Original sampling frequency in Hz
t1 = 0:1/fs1:1; % Time vector
x = t1; % Define a linear sequence
y = resample(x,3,2); % Now resample it
Error using + Matrix dimensions must agree.
Error in firls (line 161) b = b + (F(s+1)*(m*F(s+1)+b1)*sinc(2*k*F(s+1)) ...
Error in resample (line 85) h = p*firls( L-1, [0 2*fc 2*fc 1], [1 1 0 0]).*kaiser(L,bta)' ;
Akzeptierte Antwort
Weitere Antworten (6)
Thomas Carroll
am 4 Dez. 2013
0 Stimmen
1 Kommentar
Wayne King
am 4 Dez. 2013
Thomas, I have to look around for a Mac to try this on, but it works on Windows and Linux R2013b. This is very strange- I'd be very surprised that this behavior would differ on Mac
I'm assuming if you use which for resample.m you also get a path like above?
Thomas Carroll
am 4 Dez. 2013
0 Stimmen
Wayne King
am 4 Dez. 2013
Bearbeitet: Wayne King
am 4 Dez. 2013
Let's look at all the functions called by your code. Execute the following:
profile on -history
fs1 = 10;
t1 = 0:1/fs1:1; % Time vector
x = t1; % Define a linear sequence
y = resample(x,3,2); % Now resample it
p = profile('info');
for n = 1:size(p.FunctionHistory,2)
if p.FunctionHistory(1,n)==0
str = 'entering function: ';
else
str = ' exiting function: ';
end
disp([str p.FunctionTable(p.FunctionHistory(2,n)).FunctionName]);
end
Now you should get a list like this:
entering function: resample
entering function: rat
exiting function: rat
entering function: firls
entering function: signal\private\firchk
exiting function: signal\private\firchk
entering function: sinc
exiting function: sinc
entering function: sinc
exiting function: sinc
entering function: sinc
exiting function: sinc
entering function: sinc
exiting function: sinc
exiting function: firls
entering function: kaiser
entering function: signal\private\check_order
exiting function: signal\private\check_order
exiting function: kaiser
entering function: upfirdn
entering function: upfirdn>validateinput
entering function: intmax
exiting function: intmax
exiting function: upfirdn>validateinput
entering function: signal\private\upfirdnmex
exiting function: signal\private\upfirdnmex
exiting function: upfirdn
exiting function: resample
Is it possible that you have a local copy of one of those functions? like upfirdn, etc. ?
1 Kommentar
Wayne King
am 4 Dez. 2013
The code should work on Mac -- just confirmed.
Thomas Carroll
am 4 Dez. 2013
1 Kommentar
Wayne King
am 4 Dez. 2013
I would, yes. There's no reason it should not work
Thomas Carroll
am 4 Dez. 2013
0 Stimmen
4 Kommentare
Wayne King
am 4 Dez. 2013
did you attach it here? I don't see the attachment. Yes, I can diff it.
Thomas Carroll
am 4 Dez. 2013
Thomas Carroll
am 5 Dez. 2013
Wayne King
am 5 Dez. 2013
I agree this is not optimal. Thomas, can you contact tech support about this question. It sounds to me like there should be some investigating done here. You can refer them to this thread. I think you'll find them very responsive.
Jenny
am 26 Feb. 2015
This error could be caused by a third party toolbox or function shadowing the FIRLS function.
If you run the command:
>> which -all firls
it should list only MATLAB functions. If there's another FIRLS function listed, not provided by MathWorks, then uninstall the toolbox or rename your function to something else.
Kategorien
Mehr zu Digital Filtering finden Sie in Hilfe-Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!