Convert String Headers to Numbers

I am working on a program where multiple x,y,z coordinates are identified within a matrix. I am bringing in an ASCII file with one header that has 'X','Y', and 'Z' over and over again throughout multiple columns. I am wondering how to go in and replace each 'X' with a 1, each 'Y' with a 2, and each 'Z' with a 3 to better manipulate the data through a series of for loops. Any help would be greatly appreciated.

1 件のコメント

James Tursa
James Tursa 2014 年 7 月 16 日
Please post a small example of the exact format the data is in. Do you have cell arrays, or what?

サインインしてコメントする。

回答 (1 件)

Azzi Abdelmalek
Azzi Abdelmalek 2014 年 7 月 16 日

0 投票

% If your matrix looks like
M=[1 2 3 4 5 6;0 0 0 1 1 1;2 1 2 0 1 0]
out=permute(reshape(M',size(M,1),3,[]),[2 1 3])

カテゴリ

ヘルプ センター および File ExchangeData Type Conversion についてさらに検索

質問済み:

2014 年 7 月 16 日

回答済み:

2014 年 7 月 16 日

Community Treasure Hunt

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

Start Hunting!

Translated by