Re: [Scilab-users] Loop over string vector

2023-10-04 Thread Stéphane Mottelet
Hello, Here is a one liner solution: HEX=[ "FF" "D9" "CC80FF" "C2FF00" "FFB5B5" "909090" "3050F8" "FF0D0D" "90E050" "B3E3F5" ] --> matrix(hex2dec(strsplit(strcat(HEX),2:2:length(strcat(HEX))-1)),3,-1)' ans = 255. 255. 255. 217. 255. 255. 204. 128. 255. 194. 255.

Re: [Scilab-users] Loop over string vector

2023-10-04 Thread Lester Anderson
Hello Thanks for the suggestions. The 'part' option worked but the function fails at hexrgb=strsplit(x(i),[2 4])'; strsplit: Wrong size for input argument #1: A single string expected. This was the issue I was having initially, logically it should work, but looks like it just sees x as a

Re: [Scilab-users] Loop over string vector

2023-10-04 Thread Lester Anderson
Quick update. Following Serge, I managed to get from the HEX code to RGB via the following, avoiding the issue of the submatrix incorrectly defined. rgb=[part(Hex_colour,1:2),part(Hex_colour,3:4),part(Hex_colour,5:6)]; for i = 1:size(rgb,1) red(i)=hex2dec(rgb(i,1)); green(i)=hex2dec(rgb(i,2));

Re: [Scilab-users] Loop over string vector

2023-10-03 Thread Pinede Romain
Hello, A basic solution would be to use part (several times) instead of strsplit: function rgb=hex2rgb2(x) // Assuming HEX is a column vector hexrgb = [part(HEX, 1:2), part(HEX, 3:4), part(HEX, 5:6)]; rgb = hex2dec(hexrgb); endfunction Romain De : users De la part de Lester