Clear Filters
Clear Filters

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

1 view (last 30 days)
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

Answers (1)

David Hill
David Hill on 18 Oct 2022
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))

Community Treasure Hunt

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

Start Hunting!