フィルターのクリア

How to use For loop to the below data?

3 ビュー (過去 30 日間)
Haitham AL Satai
Haitham AL Satai 2023 年 6 月 5 日
コメント済み: Mathieu NOE 2023 年 6 月 28 日
I have 15 cells as shown below:
I would like to plot their data. As shown below, I drew the data for the first two cells
% First case
figure
A = berMap(1,1);
% caculate the coverage area
isSmaller = cellfun( @(X) X < 0.0038, A(:), 'UniformOutput', false);
numSmaller = sum(sum(isSmaller{:} == 1));
% Draw BerMap
Coverage_area = (numSmaller/(41*41))*400; %Important
surf(X_r,Y_r,A{1,1})
colorbar
view(0,90)
xlabel('X (m)');
ylabel('Y (m)');
zlabel('BER');
axis([-L/2 L/2 -W/2 W/2 min(min(A{1,1})) max(max(A{1,1}))]);
grid on;
hold on;
% Plotting the FEC
Amat = cell2mat(berMap(1,1));
Amat(Amat > 0.0038) = 0;
Amatrix = Amat;
Amatrix(Amat == 0) = nan;
hSurface = surf(X_r,Y_r,Amatrix);
set(hSurface, 'EdgeColor',[1 1 1],'FaceColor',[1 1 1]);
view(0,90)
%Second Case
figure
B = berMap(2,1);
% caculate the coverage area
isSmaller1 = cellfun( @(X) X < 0.0038, B(:), 'UniformOutput', false);
numSmaller1 = sum(sum(isSmaller1{:} == 1));
% Draw BerMap
Coverage_area1 = (numSmaller1/(41*41))*400; %Importrant
surf(X_r,Y_r,B{1,1})
colorbar
view(0,90)
xlabel('X (m)');
ylabel('Y (m)');
zlabel('BER');
axis([-L/2 L/2 -W/2 W/2 min(min(B{1,1})) max(max(B{1,1}))]);
grid on;
hold on;
% Plotting the FEC
Amat1 = cell2mat(berMap(2,1));
Amat1(Amat1 > 0.0038) = 0;
Amatrix1 = Amat1;
Amatrix1(Amat1 == 0) = nan;
hSurface1 = surf(X_r,Y_r,Amatrix1);
set(hSurface1, 'EdgeColor',[1 1 1],'FaceColor',[1 1 1]);
view(0,90)
I would like to use a for loop in order to draw them without writing the above codes for 15 time.
Any assistance,please?

採用された回答

Mathieu NOE
Mathieu NOE 2023 年 6 月 5 日
here you are my friend :
% main loop
for k = 1:numel(berMap)
figure
A = berMap(k);
% caculate the coverage area
isSmaller = cellfun( @(X) X < 0.0038, A(:), 'UniformOutput', false);
numSmaller = sum(sum(isSmaller{:} == 1));
% Draw BerMap
Coverage_area = (numSmaller/(41*41))*400; %Important
Amat = A{1,1};
surf(X_r,Y_r,Amat)
colorbar
view(0,90)
xlabel('X (m)');
ylabel('Y (m)');
zlabel('BER');
axis([-L/2 L/2 -W/2 W/2 min(Amat,[],'all') max(Amat,[],'all')]);
grid on;
hold on;
% Plotting the FEC
Amat(Amat > 0.0038) = 0;
Amatrix = Amat;
Amatrix(Amat == 0) = nan;
hSurface = surf(X_r,Y_r,Amatrix);
set(hSurface, 'EdgeColor',[1 1 1],'FaceColor',[1 1 1]);
view(0,90)
end
  1 件のコメント
Mathieu NOE
Mathieu NOE 2023 年 6 月 28 日
Hello
Problem solved ?

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGraphics Object Properties についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by