필터 지우기
필터 지우기

Convert String Headers to Numbers

조회 수: 1 (최근 30일)
Lindsey
Lindsey 2014년 7월 16일
답변: Azzi Abdelmalek 2014년 7월 16일
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일
% 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])

카테고리

Help CenterFile Exchange에서 Characters and Strings에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by