Why changes my string into a double in a for loop
显示 更早的评论
Hello!
When I want to change a cell in a matrix with the original value NULL into 'C', the 'C' turns into the value 67. This is my code:
for j=1:99
percentage2 = j/99
mDataTest(m,1) = str2double(data{1}{j});
mDataTest(m,2) = 0;
for i = 3:50
percentage1 = j/50
if(strcmp(data{i}{j},''))
mDataTest(m,i) = 'C';
elseif(strcmp(data{i}{j},'NULL'))
mDataTest(m,i) = 'C' ;
else
mDataTest(m,i) = str2double(data{i}{j}); %make matrix with data
end
end
m=m+1;
n=3;
end
Where data is a matrix filled with strings and numeric values. The goal of this is to change all values that are '' or 'NULL' into a string. Eventually I want to replace all 'C' with the median of that vector. Can someone help me?
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Characters and Strings 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!