Plot on x and y axes (pair)

12 visualizaciones (últimos 30 días)
Zarak Khan
Zarak Khan el 16 de En. de 2018
Respondida: Akira Agata el 16 de En. de 2018
Hello,
I would like to plot on both axis (x and y) my data looks like in pic.
So i have two runs , row1 and row1 for 28 components each.
Now i would like to plot run1 on y-axis and run2 on x-axis. and it follows the no of components (i.e 28) straight line.
something like this

Respuestas (1)

Akira Agata
Akira Agata el 16 de En. de 2018
The solution would be like:
% Assuming your data (2-by-28)
data = rand(2,28);
% Set x and y
x = data(1,:);
y = data(2,:);
% Fit to y = ax + b
p = polyfit(x,y,1);
yfit = polyval(p,x);
% View the result
figure
scatter(x,y)
hold on
plot(x,yfit)

Categorías

Más información sobre 2-D and 3-D Plots en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by