Borrar filtros
Borrar filtros

Error: The variable VAC in a parfor cannot be classified

2 visualizaciones (últimos 30 días)
Homayoon
Homayoon el 14 de Mzo. de 2016
Comentada: Walter Roberson el 9 de Feb. de 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

Respuesta aceptada

Edric Ellis
Edric Ellis el 14 de Mzo. de 2016
Editada: Edric Ellis el 15 de Mzo. de 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 comentarios
Homayoon
Homayoon el 14 de Mzo. de 2016
Thank you so much Edric and Ced!
Edric Ellis
Edric Ellis el 15 de Mzo. de 2016
Fixed my answer to put the elements in the correct order - well spotted Ced!

Iniciar sesión para comentar.

Más respuestas (1)

mohchali Alichina
mohchali Alichina el 9 de Feb. de 2022
Editada: Walter Roberson el 9 de Feb. de 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 comentario
Walter Roberson
Walter Roberson el 9 de Feb. de 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.

Iniciar sesión para comentar.

Categorías

Más información sobre Parallel for-Loops (parfor) en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by