colorbar problem in surf plot?

4 Ansichten (letzte 30 Tage)
SANDEEP SINGH RANA
SANDEEP SINGH RANA am 18 Aug. 2021
Bearbeitet: darova am 18 Aug. 2021
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

Antworten (1)

Simon Chan
Simon Chan am 18 Aug. 2021
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 Kommentare
SANDEEP SINGH RANA
SANDEEP SINGH RANA am 18 Aug. 2021
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 am 18 Aug. 2021
Bearbeitet: Simon Chan am 18 Aug. 2021
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;

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by