colorbar problem in surf plot?

4 ビュー (過去 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 Center および File ExchangeSurface and Mesh Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by