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 次查看(过去 30 天)
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');

回答(1 个)

Geoff Hayes
Geoff Hayes 2020-4-8
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 个评论
Geoff Hayes
Geoff Hayes 2020-4-8
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 2020-4-8
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().

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Number Theory 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by