i want when the user inputs on a matrix or vector to be required to include the clecius symbol how would i do tha?

1 view (last 30 days)
stoich_coeff= input('Enter a vector of stoichiometric coefficents [1x4]: ');
heat_reaction =input('Enter the heat of reaction at 25 [kJ/mol]: ');
choice= menu('Do you know the exit temperature or the heat absorbed?','KnownT_exit','KnownQ');

Answers (1)

Geoff Hayes
Geoff Hayes on 8 Apr 2020
Alex - if you just want to show the degrees symbol, then you could do something like
>> degreeSymbol = char(176); % 176 is unicode for degrees
>> fprintf('The temperature is 42%c\n', degreeSymbol);
The temperature is 42°
  3 Comments
Geoff Hayes
Geoff Hayes on 8 Apr 2020
ok so if the input string is something like
tempStr = '42°';
tempStrUnicode = double(tempStr);
if ismember(176, tempStrUnicode)
fprintf('the degree symbol exists in the input string.\n');
end
tempStrUnicode will be an array of unicode integers for each character in the string. If 176 exists (is a member) of that array, then you know that the user entered the degree symbol. You can validate if it is the last element of the array (i.e. is in the correct position) if needed.
Image Analyst
Image Analyst on 8 Apr 2020
Alex, I don't think that's what it meant. That would be a very user hostile thing to do -- require the users to know how to enter such a special symbol. Good way for your users to hate you.
I think they wanted you to just print it out on the user interface (GUI or command window) when you give a prompt string in your call to input(), or if you output some string with fprintf() or disp().

Sign in to comment.

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!