필터 지우기
필터 지우기

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