フィルターのクリア

k=1;201;

2 ビュー (過去 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 Center および File ExchangeVisual Exploration についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by