why is my cell array being read as char

4 ビュー (過去 30 日間)
janas
janas 2025 年 2 月 4 日
回答済み: Image Analyst 2025 年 2 月 4 日
I am defining two 2 parameters the same way but they are recognized differently in my code
Reference_stations = {'NUF','BRA','RFL'};
Reference_station_salinity = {'SPO','NUF','BRA','RFL'};
disp(class(Reference_stations));
cell
disp(class(Reference_station_salinity));
cell
  2 件のコメント
Mathieu NOE
Mathieu NOE 2025 年 2 月 4 日
I got "cell" in both cases on my R2020b / windows 10 PC
janas
janas 2025 年 2 月 4 日
It is weird, when I type it in the command window, it is read as "cell". But when I run my code, it changes back to char.

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

回答 (1 件)

Image Analyst
Image Analyst 2025 年 2 月 4 日
Are you sure you're getting the class of the whole cell array instead of the class of one of the contents of one cell in the array?
Reference_stations = {'NUF','BRA','RFL'};
Reference_station_salinity = {'SPO','NUF','BRA','RFL'};
disp(class(Reference_stations));
cell
disp(class(Reference_station_salinity));
cell
% Get class of just one cell in the array.
disp(class(Reference_stations(1)));
cell
disp(class(Reference_station_salinity(1)));
cell
% Get class of just one cell's CONTENTS in the array.
disp(class(Reference_stations{1}));
char
disp(class(Reference_station_salinity{1}));
char
See the FAQ to know when to use parentheses, braces, or brackets:

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by