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

1 次查看(过去 30 天)
I have two vectors A and B, and I want to plot each index of the first vector with each index of the other one. So plotting A1 with B1, A2 with B1, A1 with B3, A2 with B1...ect. Do I need to make a loop function for this? I also want to do a 3D plot of this with one of the axis being c = Ai + Bi.
A = [0.5:2:12];
B = [0:10:60];
these are the vectors I have

回答(1 个)

David Hill
David Hill 2022-10-18
A = [0.5:2:12];
B = [0:10:60];
[a,b]=meshgrid(1:length(A),1:length(B));
scatter(A(a),B(b))
scatter3(A(a),B(b),A(a)+B(b))

类别

Help CenterFile Exchange 中查找有关 Scatter Plots 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by