フィルターのクリア

How do I create a scatter plot of every value combination of three vectors?

2 ビュー (過去 30 日間)
Luke Mason
Luke Mason 2018 年 4 月 6 日
回答済み: Luke Mason 2018 年 4 月 12 日
I have three vectors each corresponding to a position of a seat in a theater. x = [0:60], y = [0:60] and z = [y.*5]. So I have an x vector, a y vector, and a z vector. I need to be able to plot every combination of the vectors because when I use scatter3(x,y,z) it plots x(n), y(n) and z(n), creating a diagonal line of seats. So I also need it to plot x(n), y(n+1), z(n+1).

採用された回答

Walter Roberson
Walter Roberson 2018 年 4 月 9 日
[X, Y, Z] = ndgrid(x, y, z);
scatter3( X(:), Y(:), Z(:));
  3 件のコメント
Luke Mason
Luke Mason 2018 年 4 月 12 日
編集済み: Walter Roberson 2018 年 4 月 12 日
clear; clc;
x = [0:90];
x = [-7:7];
z = 30*tand(12.5)
M = z.*y
amountToAdd = size(x);
L = repmat(M, amountToAdd(2), 1);
for i = [1:length(x)]
for j = [1:length(y)]
d(i,j) = sqrt((x(i)).^2+(y(j)).^2+(z*y(j))^2)
end
end
dB = 10.*log10(1./d.^2)+100;
surf(y,x,L, dB)
This is my current code. I've attached something similar to what I'm looking for but I have it as a surface and I need it as a scatter plot. I think I'm probably just not being clear with what I'm looking for
Walter Roberson
Walter Roberson 2018 年 4 月 12 日
Try the below and suggest how you want it changed.
x = 0:90;
y = -7:7;
z = 30*tand(12.5);
M = z.*y;
amountToAdd = size(x);
L = repmat(M, amountToAdd(2), 1);
for i = 1:length(x)
for j = 1:length(y)
d(i,j) = sqrt((x(i)).^2+(y(j)).^2+(z*y(j))^2);
end
end
dB = 10.*log10(1./d.^2)+100;
[X, Y] = ndgrid(x, y);
scatter3(Y(:),X(:),L(:),10,dB(:));

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

その他の回答 (2 件)

Sumeet Gadagkar
Sumeet Gadagkar 2018 年 4 月 9 日
Hey Luke,
Have you considered looping through the values of your matrix and plotting for each of the values?
It would go something like this -
% x = 0:4;
y = 0:4;
z = y*5;
q = ones(5,1);
q = q';
for i = 1:length(z)
for j = 1:length(y)
scatter3(x,y(j)*q,z(i)*q)
hold on
end
end
end
Hope this helps!
  1 件のコメント
Luke Mason
Luke Mason 2018 年 4 月 11 日
That is close to what I'm looking for, but I need the z values to only appear once so instead of a cube, I would want it to be a diagonal plane that increases in z values as the y values increase

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


Luke Mason
Luke Mason 2018 年 4 月 12 日
thats perfect, thank you

カテゴリ

Help Center および File ExchangeScatter Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by