colorbar problem in surf plot?

조회 수: 5 (최근 30일)
SANDEEP SINGH RANA
SANDEEP SINGH RANA 2021년 8월 18일
편집: darova 2021년 8월 18일
I want to plot 3D graph using 3 parameters but there is error in plotting colorbar. Matrix size of parameters and code to plot graph is as follow:
Tx_power =0:2:40; 1*21 Matrix size
Position =1:21; 1*21 Matrix size
F_cap = 21*21; Matrix size
C= Tx_power.* Position;
figure;
surf(Tx_power,Position,F_cap, C);
colorbar;
Error is:
Colorbar is not ploting and if i remove colorbar, it is working fine. And if colobar is ploting then, it is not ploting graph(i.e. F_cap parameter).
Please help

답변 (1개)

Simon Chan
Simon Chan 2021년 8월 18일
I guess the code should be like that:
Tx_power =0:2:40; %1*21 Matrix size
Position =1:21; %1*21 Matrix size
%F_cap = 21*21; % Matrix size (Not use)
[X,Y]=meshgrid(1:21,1:21); % Make a grid with size 21x21
C= Tx_power(X).*Position(Y); % Calculate C which in 2D, previous is 1D only
figure;
surf(Tx_power,Position, C);
colorbar;
  댓글 수: 2
SANDEEP SINGH RANA
SANDEEP SINGH RANA 2021년 8월 18일
Thanks Simon Chan,
But graph has 3 Dimensions.
F_cap is there as the 3 dimensions and colorbar should represent the range of values of F_cap using different color. ( In this figure, colorbar range is from 0 to 800 but in my graph plot, F_cap range is from 1 * 10^8 to 3*10^8).
Colorbar should specify ranges of F_cap. But it showing fixed range from 0 to 800 irrespective of range of 3 Dimension.
I tried below code: [it working but problem is with colorbar range and rotation]
[tp,t] = meshgrid(0:2:40,1:21);
surf(tp,t,F_cap,C);
xlabel('Tx_power (dBm)')
ylabel('simulated positions')
zlabel('Throughput in (MBps)');
colorbar;
Can you also help me in rotating graph to anti-clockwise direction so that Tx_power came in horizontal direction, Position in vertical direction and F_cap in upward direction ?
Simon Chan
Simon Chan 2021년 8월 18일
편집: Simon Chan 2021년 8월 18일
Try the following, hope this is what you want.
[t,tp] = meshgrid(1:21,0:2:40); % (Edit) Added this line after switching between x & y
surf(t,tp,F_cap);
ylabel('Tx_power (dBm)')
xlabel('simulated positions')
zlabel('Throughput in (MBps)');
colorbar;

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Directed Graphs에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by