How to change my unit to SI?

조회 수: 1 (최근 30일)
Samy Ben Thabet
Samy Ben Thabet 2018년 10월 9일
답변: Image Analyst 2018년 10월 9일
Hi I am writing a program that calculates the area of a given shape, here is an example for a square. The problem is that when I enter s=5, the end result of A is 2809 when it should be 25.
Here is the program
h=input('What shape do you want?:','s'); if strcmp(h, 'square') s=input('The length of a side is (m):','s'); A=s*s disp(A) end

채택된 답변

Star Strider
Star Strider 2018년 10월 9일
The problem is that you do not want to use the 's' option if you want a numeric input. (The 's' specifies a char input.)
Do this instead:
s=input('The length of a side is (m): ');
That will give you a numeric result for ‘s’ here.

추가 답변 (1개)

Image Analyst
Image Analyst 2018년 10월 9일
For what it's worth, see my attached spatial calibration demo.

카테고리

Help CenterFile Exchange에서 Entering Commands에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by