How to resolve "Transparency violation error" for parallel programming?
Afficher commentaires plus anciens
I am trying to use parallel programming for the following code, but I am unable to resolve the error which I am facing. Any hint/solution is highely appreciated.
%Data Import and elimination of bad taps from contour plot---------1
tic
index_file_name = linspace(1800,3600,37);
angle = linspace(180,360,37);
data2(:,667:end)=[];
parfor ii = 1:37
wind_angle = angle(ii);
Name = ['ADW100o100D040a',num2str(index_file_name(ii)),'.hdf']
data = hdfread(Name, 'Tap_Coordinates_3D');
data2 = double(transpose(hdfread(Name, 'Time_Series')));
index = find(data(2,:)==5);
tap5 = [data(:,index);data2(:,index)];
sort5 = sortrows(tap5',[5,4,3])';
clear index
index = find(data(2,:)==6);
tap6 = [data(:,index);data2(:,index)];
sort6 = sortrows(tap6',[5,4,3])';
% Single Matrix of coordinates and Timeseries
if wind_angle<=195
Timeseries = [sort5 sort6(:, 1:105) sort6(:, 107:end)];
elseif wind_angle>=205 && wind_angle<=280
Timeseries = [sort5(:, 3:end) sort6(:, 1:105) sort6(:, 107:end)];
elseif wind_angle>=240 && wind_angle<=325
Timeseries = [sort5(:, 3:end) sort6];
else
Timeseries = [sort5 sort6];
end
% Timeseries = [sort5 sort6];
x = Timeseries(4,:);
y = Timeseries(3,:);
%Voronoi and Pressure Contour--------------------2
pressure = mean(Timeseries(6:end, :))*0.001/0.657^2;
figure;
[xx, yy] = meshgrid(linspace(min(x), max(x)), linspace(min(y), max(y)));
pressure = griddata(x, y, pressure, xx, yy, 'linear');
contourf(xx, yy, pressure,10,'edgecolor', 'none')
shading interp
hold on
scatter(x, y, 'R','.')
plot ([0 125], [40 40], 'black', 'LineWidth', 0.25)
axis([0 125 0 80])
set(gca, 'Ydir', 'reverse', 'FontName', 'Times New Roman')
ylabel('Building width (ft)', 'FontName', 'Times New Roman', 'FontWeight', 'bold')
xlabel('Building length (ft)', 'FontName', 'Times New Roman', 'FontWeight', 'bold')
title(sprintf('Mean pressure contour at Roof - %d^{o} (kN/ft^2)', angle(ii)), 'fontsize', 12)
colorbar
pbaspect([1.5625 1 1])
hold off
end
toc
The output I am receiving is...
Transparency violation error.
See Workspace Transparency in MATLAB Statements.
3 commentaires
Jan
le 2 Mar 2023
Just a note not concerning the problem:
index = find(data(2,:)==5);
tap5 = [data(:,index);data2(:,index)];
clear index
% Faster with logical indexing:
index = (data(2,:)==5); % No FIND
tap5 = [data(:,index); data2(:,index)];
% clear index % This is a waste of time here!
This looks strange:
elseif wind_angle>=205 && wind_angle<=280
...
elseif wind_angle>=240 && wind_angle<=325
For wind_anle == 240 to 280 there are two options?!
Jigar
le 2 Mar 2023
Walter Roberson
le 2 Mar 2023
Note that graphics done inside parfor will not be displayed. You can do things such as capture the figure to image file, and I think you might be able to copy graphics objects back to the client.
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Matrix Indexing dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!