Finally the solution adopted was: https://www.mathworks.com/matlabcentral/answers/467879-how-do-i-write-to-a-thingspeak-channel-from-a-raspberry-pi-via-code-deployed-using-the-matlab-coder.
commandStr = [ 'sudo curl -s "https://api.thingspeak.com/update.json?api_key=' sprintf('%s', Write) '&field1=' sprintf( '%f', dato1 ) ' &field2=' sprintf( '%f', dato2) ' &field3=' sprintf( '%f', dato3) ' &field4=' sprintf( '%f', dato4) ' " ' ];
response = system(mypi, commandStr);