Effacer les filtres
Effacer les filtres

MatLab is plotting only points?

2 vues (au cours des 30 derniers jours)
John Nosh
John Nosh le 29 Sep 2017
Commenté : Jan le 30 Sep 2017
I imported an excel file into matlab and tried to plot it. But the problem is I simply get the individual points they aren't connected. How would I go about and connect those points? Thank you for helping.
Code:
[Data]=xlsread('File.xlsx');
P=Data(:,2);
n=Data(:,3);
eta=Data(:,4);
StartIndex=[1;1+find(abs(diff(Data(:,1))))];
EndIndex=[StartIndex(2:end)-1;size(Data,1)];
for i=1:length(StartIndex)
n1=n(StartIndex(i):EndIndex(i));
P1=P(StartIndex(i):EndIndex(i));
plot(n1,P1,'-o')
hold on
end
  1 commentaire
Jan
Jan le 30 Sep 2017
I have edited your question and used the "{} Code" button to improve the readability of your code.
Note that the abs() can be omitted in find(abs(diff())).

Connectez-vous pour commenter.

Réponse acceptée

Jan
Jan le 30 Sep 2017
What about:
Data = xlsread('File.xlsx');
P = Data(:,2);
n = Data(:,3);
Index = [1; 1+find(diff(Data(:,1)))];
plot(n, p);
hold on
plot(n(Index), P(index), 'o');
  2 commentaires
John Nosh
John Nosh le 30 Sep 2017
Works thank you so much. I think I was going nuts for not finding the solution.
Jan
Jan le 30 Sep 2017
Going to the forum is more convenient than going nuts. :-)

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur 2-D and 3-D Plots dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by