convert char to double

7 ビュー (過去 30 日間)
Farshid Daryabor
Farshid Daryabor 2020 年 4 月 8 日
コメント済み: Farshid Daryabor 2020 年 4 月 9 日
I really appreciate someone tell me how can I convert attached file to double.
Thanks in advance.

採用された回答

Geoff Hayes
Geoff Hayes 2020 年 4 月 8 日
Farshid - try using cellfun. It seems that the pn is a cell array with 38 elements and each element is a 8x1 char array. You haven't mentioned if each of the 8 characters is a single number or if all 8 combine to one (I'll assume the latter).
>> myData = load('example.mat');
>> numericData = cellfun(@(x)str2double(x'), myData.pn);
  8 件のコメント
Geoff Hayes
Geoff Hayes 2020 年 4 月 9 日
Farshid - it probably would have been easier if you had just asked for that format in the first place.
myData = load('example.mat');
myOutputData = nan(2,length(myData.pn));
for k = 1:length(myData.pn)
data = myData.pn{k};
myOutputData(1,k) = str2double(data(:,1)');
if size(data,2) == 2
myOutputData(2,k) = str2double(data(:,2)');
end
end
Farshid Daryabor
Farshid Daryabor 2020 年 4 月 9 日
Dear Geoff,
I really appreciate, veryyyyygoodddddddddd

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCell Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by