필터 지우기
필터 지우기

테이블 데이터 수정작업 할때 (For Type of Table)

조회 수: 15 (최근 30일)
MINHOON KIM
MINHOON KIM 2020년 3월 13일
편집: Sourabh Kondapaka 2020년 3월 27일
<Table : a> <Table : Modified_a>
>> a.Var1{1} = 'Cell1';
>> a(2,1) = {{'Cell2'}};
제일 아래 수준의 데이터 타입을 참조하여 수정하는 것과 마찬가지로, Table 타입 수준에서 참조한뒤 그 것을 바꾸려면 Table 대입식 {} 쓴뒤 그안에 Cell을 쓰기위해 {}이걸 또 쓴걸로 알고 있습니다.
>> a.Var3(1) = 'a';
>> a(2,3) = {'a'};
cell에서 double(으)로 변환될 수 없습니다.
>> a(2,3) = 'a';
테이블 대입식의 우변은 또 다른 테이블이거나 셀형 배열이어야 합니다.
해서, Double 타입의 열의 데이터를 수정하기 위해 위와 같이 비교해보았는데 오류가 뜹니다.
>> a.Var2(1) = "String1";
>> a(2,2) = "String2";
테이블 대입식의 우변은 또 다른 테이블이거나 셀형 배열이어야 합니다.
>> a(2,2) = {"String2"};
>> a(3,2) = {'Chracter'};
앞의 방식을 String 형에 다 적용 해보니 다 만족했으며
마지막 Character 형태의 경우 저절로 String으로 바껴서 들어가던데
Double 에서는 a(2,3) = {'a'}; 이렇게 할때 왜 안되는지 모르겠습니다.
ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ
>> a.Var1 {1} = 'Cell1';
>> a (2,1) = {{'Cell2'}};
As with modifying by referring to the lowest level data type, to change it after referencing it at the table type level, I know that I wrote another {} to write a cell after writing a table assignment {}.
>> a.Var3 (1) = 'a';
>> a (2,3) = {'a'};
It cannot be converted from cell to double.
>> a (2,3) = 'a';
The right side of the table assignment must be another table or a cell array.
So, I tried to edit the data of the double type column as above, but I get an error.
>> a.Var2 (1) = "String1";
>> a (2,2) = "String2";
The right side of the table assignment must be another table or a cell array.
>> a (2,2) = {"String2"};
>> a (3,2) = {'Chracter'};
I applied the previous method to the String type, and I was satisfied.
In the case of the last character type, it was converted into a string by itself.
In Double, a (2,3) = {'a'}; I am not sure why this is not the case.

답변 (1개)

Sourabh Kondapaka
Sourabh Kondapaka 2020년 3월 27일
편집: Sourabh Kondapaka 2020년 3월 27일
Hi,
In the table a.matandModified_a.mat” , the data type of the third column “Var3” is “double”. So, changing a value in any cell of that column will expect only a double datatype.
%So instead of:
a(2,3) = {a}
%You can do:
a(2,3) = {37};
%Or
a(2,3) = {5.85};

카테고리

Help CenterFile Exchange에서 테이블에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!