I am curious when using the reference function on a table to modify data.

5 views (last 30 days)
<Table : a> <Table : Modified_a>
If you code as below with reference to the above tables,
>> 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.
ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ
위의 테이블들을 참조하여 아래와 같이 코딩 하면,
>> 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'}; 이렇게 할때 왜 안되는지 모르겠습니다.

Answers (0)

Categories

Find more on 문자형과 string형 in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!