Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一列只有whole numbers它,我需要11在前面附加一个数字(比如) -
whole numbers
11
data = (1:1300000)'; % append 11 to these numbers newdata = [111 ; 112 ; 113 ; 114 ; ......]
有没有办法在不使用str2num(由于速度问题)的情况下做到这一点?谢谢。
str2num
如果你取以 10 为底的对数data,你可以找出你需要乘以多少 11,这样你就可以把它变成一个简单的加法。
data
%# create some test data data = [1 22 123]; %# add 11*10^x to data so that the two ones end up in front of the number newData = 11*10.^(floor(log10(data))+1)+data newData = 111 1122 11123