Filling array with dec2hex() value
이전 댓글 표시
Hello,
I have an issue with fill my matrix after the use of dec2hex() function.
As the first step, I allocate space for a three-column matrix. The next step is to generate a random number and delete the decimal part of the number. Which are saved to the first column of matrix. In the last step, I want to converse decimal value to hexadecimal value by dec2hex() function. The conversion to show me basic error: " Unable to perform assignment because the size of the left side is 1-by-1 and the size of the right side is 1-by-2." Is the problem with the output of the dec2hex() function?
Could you help me with the issue?
%%allocation memory for matrix
for n=1:len
data_extend(n,1) = 0;
data_extend(n,2) = 0;
data_extend(n,3) = 0;
end
%randomize fill of data_extend array
a = 0;
b = 255;
for n=1:len
data_extend(n,1) = (b-a).*rand(1,1) + a; %%rand number from interval 0-255; a-b
data_extend(n,1) = floor(data_extend(n,1)); %%delete decimal
end
%%conversion decimal to hex
for n=1:len
data_extend(n,3) = dec2hex(data_extend(n,1));
end
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Data Type Conversion에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!