Clear Filters
Clear Filters

Error: The variable VAC in a parfor cannot be classified

2 views (last 30 days)
Dear All,
I read some of the solutions to the error mentioned in the subject of this question but they all seemed vague to me. I have a code as follows:
VAC = zeros(taw_max ,2);
parpool ('local',12)
parfor taw = 0:1:taw_max
taw_matrix = zeros(n-taw , 1);
for t = 0:(n-1-taw)
allmatrix = zeros (nt,1);
for i=1:nt
allmatrix (i,1) = mh * dot (s_t , s_t_taw )/dot(s_t , s_t); %where s_t . s_t_taw and mh are all defined values
end
taw_matrix (t+1 ,1) = sum(allmatrix);
end
VAC (taw +1 ,2) = mean (taw_matrix);
VAC (taw +1 ,1) = taw ;
end
it seems that the parfor loop can not classify the VAC matrix so that I can not write the output of my calculations into the corresponding cell of the VAC matrix. Would you please help me with a solution to this matter?
Thank you so much

Accepted Answer

Edric Ellis
Edric Ellis on 14 Mar 2016
Edited: Edric Ellis on 15 Mar 2016
I think you simply need to ensure that you make only a single assignment into VAC, as the code analyzer message suggests. Like this:
VAC(taw + 1, :) = [taw, mean(taw_matrix)];
  3 Comments
Edric Ellis
Edric Ellis on 15 Mar 2016
Fixed my answer to put the elements in the correct order - well spotted Ced!

Sign in to comment.

More Answers (1)

mohchali Alichina
mohchali Alichina on 9 Feb 2022
Edited: Walter Roberson on 9 Feb 2022
I have a function and I need to apply this function to an electrician field ( apply waveform to ion motion) . Kindly can anyone guide me to do it! thanks in advance
Fs=25.8e6;
%run swiftfunccycle10ms function
[y,swiftT] = swiftfunccycle10ms(100,10e3,300e3,67e3,80e3,20e3,67e3,80e3);
%------------------------------------
s=real(swiftT);
[cfs,frq] = cwt(s,Fs); %continues wavelet transform
tms = (0:numel(s)-1)/Fs;%length of s
figure
subplot(2,1,1)
plot(tms,s)
axis tight
title('swiftT Scalogram')
xlabel('Time (s)')
ylabel('Amplitude')
subplot(2,1,2)
surface(tms,frq,abs(cfs))
axis tight
shading flat
xlabel('Time (s)')
ylabel('Frequency (Hz)')
%set(gca,'yscale','log')
ylim([10000 500000]);
%---------------------------------------------
%run swiftfunccycle function
[y, signalT]=signalfunccycle(0.1,10000,300000,67000,80000,200000);
%---------------------------------------------
s=real(signalT);
[cfs,frq] = cwt(s,Fs); %continues wavelet transform
tms = (0:numel(s)-1)/Fs;%length of s
figure
subplot(2,1,1)
plot(tms,s)
axis tight
title('signalT Scalogram')
xlabel('Time (s)')
ylabel('Amplitude')
subplot(2,1,2)
surface(tms,frq,abs(cfs))
axis tight
shading flat
xlabel('Time (s)')
ylabel('Frequency (Hz)')
%set(gca,'yscale','log')
ylim([10000 500000])
  1 Comment
Walter Roberson
Walter Roberson on 9 Feb 2022
Where you are using parfor that this might apply?
Your signalfunccycle and swiftfunccycle10ms are not found anywhere on the Internet that I can see, so we cannot test your code.

Sign in to comment.

Categories

Find more on Parallel for-Loops (parfor) in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!