フィルターのクリア

How to draw 3D bar graph of Z for specified value of X and Y.

43 ビュー (過去 30 日間)
Shashibhushan Sharma
Shashibhushan Sharma 2018 年 8 月 21 日
回答済み: Shashibhushan Sharma 2018 年 8 月 30 日
Dear all, I want to plot a 3D bar graph for a given X, Y and Z row matrix. Actually I want to plot bar of Z for a specified coordinate of X and Y in X-Y plane. How to plot it please help me
  2 件のコメント
Julie
Julie 2018 年 8 月 21 日
So do you have multiple Z values for each X and Y?
Shashibhushan Sharma
Shashibhushan Sharma 2018 年 8 月 22 日
yes multiple z value for multiple values of X and Y.

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

採用された回答

Dimitris Kalogiros
Dimitris Kalogiros 2018 年 8 月 21 日
編集済み: Dimitris Kalogiros 2018 年 8 月 21 日
I thing you should use stem3 command.
Have a look at the following example:
clear; close all; clc;
x = 0:1:10;
y = exp(2:-0.2:0);
z=sqrt(x)+2*((y.^2).^(1/3));
stem3(x,y,z, '-b','LineWidth',4);
xlabel('x'); ylabel('y'); zlabel('z');
zoom on; grid on;
stem3() produced "bar like" 3D graphs
  3 件のコメント
Dimitris Kalogiros
Dimitris Kalogiros 2018 年 8 月 22 日
編集済み: Dimitris Kalogiros 2018 年 8 月 22 日
clear; close all; clc ;
% definition of x, y
x1 = 0:1:10 ;
y1 = 2:12;
% define a set of colors
rng(8881);
colorSet=[rand(1,length(x1)); (length(x1):-1:1)/length(x1); rand(1,length(x1))]';
% definition of z
z=zeros(length(x1),length(y1));
for q=1:length(x1)
x=x1(q);
for w=1:length(y1)
y=y1(w);
z(q,w)=sqrt(x)+2*((y.^2).^(1/3 ));
%color depends on x value
stem3(x,y,z(q,w), '-b','color',colorSet(q,:),'LineWidth',4);
hold on;
end
end
xlabel('x'); ylabel('y'); zlabel('z ')
zoom on; grid on;
Shashibhushan Sharma
Shashibhushan Sharma 2018 年 8 月 22 日
Thank you sir, but still one question arise that why do we not plot it in bar graph.

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

その他の回答 (1 件)

Shashibhushan Sharma
Shashibhushan Sharma 2018 年 8 月 30 日
We can plot 3D bar graph in MATLAB for specific values of x and y as:
clearvars;close all;clc; x1=1:10;y1=0:0.1:1;z=zeros(length(y1), length(x1)); for a=1:length(x1) x=x1(a); for b=1:length(y1) y=y1(b); z(b,a)=((1/x)^2)+exp(y); end end bar3( z (:,:,1)); set(gca,'XTickLabel',x1) set(gca,'YTickLabel',y1)

カテゴリ

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