Changing a string to a number

1 次查看(过去 30 天)
Jason
Jason 2014-2-5
I have a table that contains both numerical values as well as text. I would like to replace the string 'N/A' to the number 0 in the table.
Thanks for helping out a true beginner.

回答(1 个)

Azzi Abdelmalek
Azzi Abdelmalek 2014-2-5
A={1 2 'N/A';3 'B' 5;'N/A' 0 0} %Example
A(strcmp(A,'N/A'))={0}
  2 个评论
Jason
Jason 2014-2-6
Thanks, this got me part of the way there, but it doesn't work for tables.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Characters and Strings 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by