Inoperability between Mac (Intel) and Windows

1 visualizzazione (ultimi 30 giorni)
I am developing on a Mac. My partner is using a Windows box. We have something happen that I can't understand. It was a simple task - I wanted to select a sub portion of an array and set outside of that portion to be zero out. I defined the indices by a variable "filt". I created a zero array call it y of the proper length and set y(filt)=x(filt) where x is the original array.
It worked fine on the Mac but barfed on the Windows box. After much aggravation I tried changing the name of the index parameter to "idx_filt" and it worked fine on both.
Any explanation would be greatly appreciated. I cannot find anything on the documentation on Matlab on my Mac that indicates that "filt" might be a forbidden variable name.
  3 Commenti
Jason Ross
Jason Ross il 18 Apr 2011
Specific error messages?
Version of Windows, OSX?
Version of MATLAB on both machines?
Truman
Truman il 18 Apr 2011
Here is the code
Config
Config_freq
ampl_raw = data(2:2:(n_freq*2));
ampl = mod(ampl_raw,2^24);
ampl_num0 = bitshift(ampl_raw - ampl,-24);
ampl_num=ampl_num0;
zeros_ind = find(ampl_num==0);
inter_ind = find(ampl_num<n_cycle & ampl_num~=0);
num_cycle=n_cycle;
ampl_num(zeros_ind)=1; % exclude div by 0
ampl = sqrt(ampl*256*num_cycle./ampl_num);
phase1 = 2*(mod(mod(data(1:2:(n_freq*2)),2^32)*num_cycle./ampl_num+2^31,2^32)-2^31)/2^32*pi;
phase0=phase1;
phase0=phase0/2; % for real time loopback
% phase0=(data(1:2:n_freq*2)/2^31*pi)./2;
% phase0 = unwrap(2*(mod(mod(data(1:2:(n_freq*2)),2^32)*num_cycle./ampl_num+2^31,2^32)-2^31)/2^32*pi)/2;
if max(ampl)>0
ampl_norm=ampl/max(ampl);
else
ampl_norm=ampl;
end
amp=zeros(1,length(ampl_norm));
amp(idx_filt)=ampl_norm(idx_filt);
ampl_norm=amp;
sig.num_ave=ampl_num0;
sig.amp=ampl_norm;
sig.amp_raw=ampl;
sig.diff_phase=phase0;
This code works. idx_filt is defined in the file Config_filt. If idx_filt is changed to filt with the same values then it throws an error on the Matlab in Windows while it works fine on the Mac. The error is at the line
amp(filt)=ampl_norm(filt).
Windows 7 - Matlab version 2010a and 2008b (same error on both)
OSX 10.6.7 - Matlab version 2011a
I have the Mac - may partner has the Windows box. I don't remember the exact error, however, it threw a fatal error because of the indexing. Change the index variable name idx_filt it worked fine.
I alos changed the code instead of
amp(filt)=ampl_norm(filt);
to
amp=zeros(1,length(ampl_norm));
for n=1:length(filt)
amp(filt(n))=ampl_norm(filt(n));
end
just to see what was going on. The Windows box threw the same error message.
I was quite surprised to see this happen.

Accedi per commentare.

Risposta accettata

Rob Graessle
Rob Graessle il 18 Apr 2011
'filt' is the name of a function in the Control System Toolbox:
>> doc filt
Perhaps the Mac does not have Control System Toolbox installed while the PC does. In any case, you should avoid using 'filt' as a variable name.

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by