필터 지우기
필터 지우기

Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

Problems with Displying Function Output

조회 수: 1 (최근 30일)
kenny
kenny 2013년 6월 6일
마감: MATLAB Answer Bot 2021년 8월 20일
hey, guys! this is my first post, so watch out. I'm having displaying my result in matlab for this program i'm trying to make that converts grams of an element (in this case Helium) to moles of that element. I'm not really a programmer but i thought it would be fun. I'm trying to get the program to divide the input of "grams" by 4. but it's not working. any advice? thanks
elmnt = input('what is the element? ','s');
grams = input ('how many grams?');
if strcmp(elmnt, 'He')
disp (grams/4)
else disp (' that''s not the right element')
end
  댓글 수: 2
Marshall
Marshall 2013년 6월 6일
This code appears to be working fine for me. Have you considered using fprintf?
fprintf('%d moles of He\n', grams/4);
kenny
kenny 2013년 6월 6일
that works! thanks.

답변 (0개)

이 질문은 마감되었습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by