Effacer les filtres
Effacer les filtres

Error: The variable VAC in a parfor cannot be classified

2 vues (au cours des 30 derniers jours)
Homayoon
Homayoon le 14 Mar 2016
Commenté : Walter Roberson le 9 Fév 2022
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

Réponse acceptée

Edric Ellis
Edric Ellis le 14 Mar 2016
Modifié(e) : Edric Ellis le 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 commentaires
Homayoon
Homayoon le 14 Mar 2016
Thank you so much Edric and Ced!
Edric Ellis
Edric Ellis le 15 Mar 2016
Fixed my answer to put the elements in the correct order - well spotted Ced!

Connectez-vous pour commenter.

Plus de réponses (1)

mohchali Alichina
mohchali Alichina le 9 Fév 2022
Modifié(e) : Walter Roberson le 9 Fév 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 commentaire
Walter Roberson
Walter Roberson le 9 Fév 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.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Parallel for-Loops (parfor) dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by