Finding a column with specific text
    8 ビュー (過去 30 日間)
  
       古いコメントを表示
    
I am trying to create a function that takes a array of characters and finds the first column that has a specific input. It seems to work however when I ask have cells with multiple characters an error message saying matrix dimensions must agree. Not sure what I am doing wrong. Any suggestions?

0 件のコメント
採用された回答
  Star Strider
      
      
 2021 年 2 月 15 日
        3 件のコメント
  Adam Danz
    
      
 2021 年 2 月 15 日
				
      編集済み: Adam Danz
    
      
 2021 年 2 月 15 日
  
			strcmp/strcmpi returns the index number. 
If your array is 1D (vector) then you're problem is solved.  
If your array is >1D you can use ind2sub to get the column number. 
ind = strcmpi(YourArray, subStr);
[~, col] = ind2sub(size(YourArray),find(ind));
その他の回答 (0 件)
参考
カテゴリ
				Help Center および File Exchange で Matrices and Arrays についてさらに検索
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


