new to matlab simple question

조회 수: 1 (최근 30일)
HrMmz
HrMmz 2016년 11월 28일
댓글: bio lim 2016년 11월 28일
when you do a computation ie c=(b+a)/2 will this automatically display in matlab? i'm new to MATLAB but not programming at all and was just wondering if there is a display command or if all calculations are displayed which would make most sense to me since MATLAB is just math calculations...

채택된 답변

bio lim
bio lim 2016년 11월 28일
편집: bio lim 2016년 11월 28일
Yes it will, assuming that you have previously defined the values for a,b,c obviously.
If you write semicolon at the end of your c=(b+a)/2; then it won't display.
  댓글 수: 2
HrMmz
HrMmz 2016년 11월 28일
okay wait, so to display the command you just leave out the semi-colon am I understanding that right? Also one more thing..
Sorry more beginner stuff..
So if I leave out a semi colon ie..
a + (b-a)*rand()
%gives uniform random values in the interval [a,b]
c = (b+a)/2
%calculating mean of values of mean between 1 and 2
((b-a)^2)/12
those commands are line by line and will just output a display? makes sense thanks..
bio lim
bio lim 2016년 11월 28일
Yes, all of them will display their outputs on new lines. If I run your above program with (in this case it won't give any outputs since we ended it with semicolons):
a = 1;
b = 2;
My output in command window is:
ans =
1.8147
c =
1.5000
ans =
0.0833
Also, if you don't define a variable when you are doing an operation, e.g., ((b-a)^2)/12, MATLAB names the output ans.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

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