I have matrix A =[nx1] & B = [nx1] I want to combine them into C = [ nx2]

2 views (last 30 days)
I tried to do plot ( A,B) But it showed me 2 lines in one plot
Because I wanted to make A as x-axis & B as y axis in plot

Accepted Answer

Guillaume
Guillaume on 3 Nov 2017
The title of your question has nothing to do with the body of your question.
To answer your title:
C = [A, B];
To answer the body:
plot(A, B)
is indeed the correct syntax to plot B as y values and A as x values. If you get 2 lines in the legend, that would be because B has twice the numbers of rows or columns of A. If A and B are indeed both nx1, you cannot get two lines.
  5 Comments
Rashid Hussein
Rashid Hussein on 4 Nov 2017
Edited: Rashid Hussein on 4 Nov 2017
Thank you and for the function name , then yes I misspelled the name here , anyway I have a clue of what I should do & thank you again sir .

Sign in to comment.

More Answers (1)

KL
KL on 3 Nov 2017
Edited: KL on 3 Nov 2017
C = [A, B]
for plotting A against B, you are right,
plot(A,B)

Categories

Find more on Labels and Annotations in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!