colorbar problem in surf plot?
5 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
回答(1 个)
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 个评论
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;
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!