convert cell to integer
显示 更早的评论
I have a 1*1 cell in which its content is ineger. I need to convert the content to integer (no cell anymore just like a number itself)
how can I do that?
I tied cell2mat but did not work. It is like this now:
kar =
1×1 cell array
{[3]}
3 个评论
"I tried cell2mat but it did not work"
What does that mean? Did you get an error? If so, what was the full error message? If your example accurately describes your data, it should work.
kar = {[3]};
cell2mat(kar)
% ans =
% 3
madhan ravi
2019-8-16
whos kar % Paste the results from command window here
While you're at it, let us know what this returns or if it returns an error, too.
class(kar{:})
size(kar{:})
回答(1 个)
Star Strider
2019-8-16
If ‘kar’ is initially:
kar = {{[3]}};
try this:
n = cell2mat(kar{:})
producing:
n =
3
类别
在 帮助中心 和 File Exchange 中查找有关 Cell Arrays 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!