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));
blue(i)=hex2dec(rgb(i,3));
RGB_colours=cat(2,red,green,blue);
end

On Tue, 3 Oct 2023 at 12:42, Lester Anderson 
<arctica1...@gmail.com<mailto:arctica1...@gmail.com>> wrote:
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 whole.

Lester

On Tue, 3 Oct 2023 at 08:03, Steer Serge 
<serge.st...@laposte.net<mailto:serge.st...@laposte.net>> wrote:
With a for loop

function rgb=hex2rgb(x)
    // x=string input
   rgb=[];
   for i=1:size(x,"*")
       hexrgb=strsplit(x(i),[2 4])';
    rgb=[rgb;hex2dec(hexrgb)];
  end
endfunction


You can also use the part function which works with vectors
rgb=[part(x,1:2),part(x,3:4),part(x,5:6)];

Le 02/10/2023 à 09:52, Lester Anderson a écrit :
Hello,

I am trying to loop through a vector of strings but having issues with the 
strsplit function.

The vector consists of HEX values for colours. I created a simple function to 
get RGB values.

function rgb=hex2rgb(x)
    // x=string input
    hexrgb=strsplit(x,[2 4])';
    rgb=hex2dec(hexrgb);
endfunction

--> HEX
 HEX  =

  "FFFFFF"
  "D9FFFF"
  "CC80FF"
  "C2FF00"
  "FFB5B5"
  "909090"
  "3050F8"
  "FF0D0D"
  "90E050"
  "B3E3F5"
etc

The function works fine with single values as that is what strsplit expects, 
but not sure how to make it run through the string vector; indexing causes 
issues. Any pointers would be helpful.

Thanks
Lester

This email and any attachments are intended solely for the use of the 
individual or entity to whom it is addressed and may be confidential and/or 
privileged.

If you are not one of the named recipients or have received this email in error,

(i) you should not read, disclose, or copy it,

(ii) please notify sender of your receipt by reply email and delete this email 
and all attachments,

(iii) Dassault Systèmes does not accept or assume any liability or 
responsibility for any use of or reliance on this email.


Please be informed that your personal data are processed according to our data 
privacy policy as described on our website. Should you have any questions 
related to personal data protection, please contact 3DS Data Protection Officer 
https://www.3ds.com/privacy-policy/contact/




_______________________________________________
users mailing list - users@lists.scilab.org<mailto:users@lists.scilab.org>
Click here to unsubscribe: 
<mailto:users-unsubscr...@lists.scilab.org><mailto:users-unsubscr...@lists.scilab.org>
https://lists.scilab.org/mailman/listinfo/users



This email and any attachments are intended solely for the use of the 
individual or entity to whom it is addressed and may be confidential and/or 
privileged.

If you are not one of the named recipients or have received this email in error,

(i) you should not read, disclose, or copy it,

(ii) please notify sender of your receipt by reply email and delete this email 
and all attachments,

(iii) Dassault Systèmes does not accept or assume any liability or 
responsibility for any use of or reliance on this email.


Please be informed that your personal data are processed according to our data 
privacy policy as described on our website. Should you have any questions 
related to personal data protection, please contact 3DS Data Protection Officer 
https://www.3ds.com/privacy-policy/contact/

_______________________________________________
users mailing list - users@lists.scilab.org
Click here to unsubscribe: <mailto:users-unsubscr...@lists.scilab.org>
https://lists.scilab.org/mailman/listinfo/users

Reply via email to