Replace empty string with NaN in a cell
조회 수: 156 (최근 30일)
이전 댓글 표시
I have a cell called A={ "20" "25" "25" [] "20" [] "25" "25" "25" "30"}
I would like to replace cell A with A={ "20" "25" "25" "NaN" "20" "NaN" "25" "25" "25" "30"}
Any help is highly appreciate, thank you.
댓글 수: 0
채택된 답변
추가 답변 (1개)
Awais Saeed
2021년 8월 23일
편집: Awais Saeed
2021년 8월 23일
clc;clear;close all;
A={ "20" "25" "25" [] "20" [] "25" "25" "25" "30"}
% get locations of empty cell elements
idx = cellfun('isempty',A);
% replace those empty cells with NaN
A(idx) = {NaN}
참고 항목
카테고리
Help Center 및 File Exchange에서 Characters and Strings에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!