How to display the indices data in command window automatically?

3 views (last 30 days)
Manoj on 13 Jul 2018
Commented: Manoj on 16 Jul 2018
Find the attachment of the data contains 2 columns, 1st column is sequential increment values and 2nd one is before and after 0 data is there w.r.t the 1st column. I need to read only the indices data (say @11.2 and 13.5 )and display in command window . Along with that if I plot 1st column versus 2nd column, at that particular indices data i need to display the text with horizontal or vertical alignment and markers also. thanking you

Answers (1)

Peter Meglis
Peter Meglis on 13 Jul 2018
Edited: Peter Meglis on 13 Jul 2018
Hi Manoj,
From my interpretation it sounds like you want to get values from the second column of a table based on a condition (like the data is 13.5) from the first column, as well as plot multiple values and add markers or labels. Here is some sample code that I wrote up doing that:
table = readtable('data.xls');
table.Properties.VariableNames = {'ColA', 'ColB'};
% Indexing based on condition
value = table.ColB(table.ColA == 12.6)
% Indexing based on multiple values
rowIdx = ismember(table.ColA, [11.1 12.6 13.5]);
multipleValues = table(rowIdx, :)
xs = multipleValues.ColA;
ys = multipleValues.ColB;
plot(xs, ys, 'o')
text(xs, ys, 'Text', 'HorizontalAlignment', 'left', 'VerticalAlignment','top');
xlabel('X Axis');
ylabel('Y Axis');
Hopefully this helps you get started, if you want more information, take a look at:
  1 Comment
Manoj on 16 Jul 2018
Thank you for your reply.Output plot is okay. But I need only the indices of 11.7 and 13.5, should be detectable automatically.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!

Translated by