0

I have the following array:

A = {'E1_02' nan nan nan nan nan;
'Time'  'Force' 'Stress'    'Stroke'    'Ext.1' 'Width1';
'sec' 'N' 'N/mm2'   'mm'    'mm'    'mm'}

which gives

{'E1_02'}    {[  NaN]}    {[   NaN]}    {[   NaN]}    {[  NaN]}    {[   NaN]}
{'Time' }    {'Force'}    {'Stress'}    {'Stroke'}    {'Ext.1'}    {'Width1'}
{'sec'  }    {'N'    }    {'N/mm2' }    {'mm'    }    {'mm'   }    {'mm'    }

This is the start of a very long .csv with data in every column. I would like to find the row and column indices of one of the strings, for example ' Stress', because then I would like to extract the data in that column. I tried find but from what I understand it just check if the string is present in a row or column but does not return the indices of the string's location. What I would like is something like

What string do you want?: ' Stress'
Search through array...
Here are the coordinates for that string: [row column] = [3 2]

Should I make a loop that checks every row and column for the string and then use those as the indices? Or did I misunderstand the way find works?

2
  • 1
    The documentation for find pretty clearly states that it returns indices. What exactly are you asking? Commented Feb 16, 2018 at 2:59
  • Apologies, I misunderstood the documentation. Commented Feb 18, 2018 at 4:02

1 Answer 1

1

You could use:

[row, col] = find(strcmp(A,'Stress'))

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.