필터 지우기
필터 지우기

k=1;201;

조회 수: 3 (최근 30일)
buxZED
buxZED 2011년 3월 1일
k=1;201;
What dose this mean in english?

채택된 답변

Walter Roberson
Walter Roberson 2011년 3월 2일
As asked:
A variable named "k" is to be created. The variable is to be assigned a value. The value to be assigned is the list of numbers that is the single number 1. The ";" that follows that indicates that the result of the assignment is not to be displayed. That is the end of that bit of execution, and the rest of the line is evaluated separately. The value 201 is constructed, and as it is not used in any other way, its value is to be assigned to the default variable named "ans". The ";" that follows that indicates that the result of the assignment is not to be displayed.
But what you probably meant to ask about was
k=1:201;
with a ":" between the numbers instead of a ";". The meaning of that would be:
A variable named "k" is to be created. The variable is to be assigned a value. The value to be assigned is the list of numbers starting from 1, incrementing by 1, until the last number that is less than or equal to 201. The ';' means that the result of doing the assignment is not to be displayed.
Note that k=1:201; would have a different but related meaning if proceeded by the keyword "for", as in
for k=1:201;

추가 답변 (1개)

Matt Fig
Matt Fig 2011년 3월 1일
It means: set the variable k to equal 1, then set the variable ans to 201, displaying nothing.
You can see this by executing these lines at the command window:
clear all,clc
k=1;201;
whos
k
ans
Now, if you had put this:
k=1:201; % Note the colon.
that would mean: set the variable k to a vector of length 201 with the elements 1 through 201, inclusive.

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by