MATLAB Answers

I did plot(x,y) with a set of data that is not in oder, and now my line plot looks terribly wrong. How can I fix this?

2 views (last 30 days)
Samantha Chin
Samantha Chin on 24 Jan 2020
Answered: Walter Roberson on 24 Jan 2020
So my code is pasted below, but I am really confused. I expected the line to go in order, but the line is going everywhere. can someone please help me
Blegh.jpg
%% Part 2
data=xlsread('HWL 1 Data.xlsx');
% Separating data based on category
Heightdata= data(:,2);
Legdata= data(:,3);
Footdata= data(:,4);
Stridesdata= data(:,5);
StrideLengthdata= data(:,6);
StrideFreqdata= data(:,7);
Speeddata= data(:,8);
%% Means using mean() function
Heightmean= mean(Heightdata);
Legmean= mean(Legdata);
Footmean= mean(Footdata);
Stridesmean= mean(Stridesdata);
StrideLengthmean= mean(StrideLengthdata);
StrideFreqmean= mean(StrideFreqdata);
Speedmean= mean(Speeddata);
%% Standard Deviation using std() function
Heightstd= std(Heightdata);
Legstd= std(Legdata);
Footstd= std(Footdata);
Stridesstd= std(Stridesdata);
StrideLengthstd= std(StrideLengthdata);
StrideFreqstd= std(StrideFreqdata);
Speedstd= std(Speeddata);
%% Plots
figure()
x1= Heightdata
y1= Legdata
scatter(x1,y1);
figure()
plot(x1,y1);

  0 Comments

Sign in to comment.

Answers (1)

Walter Roberson
Walter Roberson on 24 Jan 2020
Before doing any processing, sortrows data based on column 2.
https://www.mathworks.com/help/matlab/ref/double.sortrows.html

  0 Comments

Sign in to comment.

Sign in to answer this question.

Tags


Translated by