Filling array with dec2hex() value
Show older comments
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
Accepted Answer
More Answers (0)
Categories
Find more on Data Type Conversion in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!