필터 지우기
필터 지우기

extract data from a matrix

조회 수: 1 (최근 30일)
Linden
Linden 2013년 8월 5일
Hi, My matrix contains 200 X variables and 20 Z variables. All of them are properly named with a string name, i.e., X1...X200,Z1...Z20. How can I extract Zs out by using the string names, i.e. don't use column numbers. Many thanks.
  댓글 수: 1
David Sanchez
David Sanchez 2013년 8월 5일
How/Where are you storing the name strings? Are they in an independent cell array?

댓글을 달려면 로그인하십시오.

답변 (1개)

Jan
Jan 2013년 8월 5일
Using "X1" to "X200" is a really bad idea, see FAQ: How to create A1, A2, ... in a loop. Such hiding of an index in a name of a variable demands for complicated methods for the creation and access without offering any benefit.
It is not clear how the variables are stored in your "matrix", because matrices cannot contain "names". Are you talking about a cell of structs? Please post a meaningful example in valid Matlab syntax. Please add the new information by editing the original question, where readers expect all required information, while neither adding a comment or pseudo-answer is useful.
  댓글 수: 1
Linden
Linden 2013년 8월 5일
Hi Jan, thanks for your help. Data is read in from an excel sheet with Xs and Zs as names. So I have a matrix containing both the name of variables and values (A), a matrix only containing string of names (B) and a matrix containing values (C). I know how to extract variables from C. Suppose Z is from column 201 to 220 in C, can we use variable names to extract Z, rather than use C(:,201:220). Many thanks.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Structures에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by