Error: The variable VAC in a parfor cannot be classified

6 次查看(过去 30 天)
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

采纳的回答

Edric Ellis
Edric Ellis 2016-3-14
编辑:Edric Ellis 2016-3-15
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 个评论
Edric Ellis
Edric Ellis 2016-3-15
Fixed my answer to put the elements in the correct order - well spotted Ced!

请先登录,再进行评论。

更多回答(1 个)

mohchali Alichina
编辑:Walter Roberson 2022-2-9
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 个评论
Walter Roberson
Walter Roberson 2022-2-9
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.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Array Geometries and Analysis 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by