【matlab】数组赋值,用户输入
来源:百度知道 编辑:UC知道 时间:2024/07/02 22:43:44
输入一维数组的5个元素,我是这样写的,因为受C++影响太深。。。
for i=1:5
x(i)=input('输入元素');
end;
老师给了批注,如下:
x=input('vector_');
难道可以直接一次性输入数组的5个元素吗?我试了几次,没有试出来。。。
请大家帮帮我呀。
for i=1:5
x(i)=input('输入元素');
end;
老师给了批注,如下:
x=input('vector_');
难道可以直接一次性输入数组的5个元素吗?我试了几次,没有试出来。。。
请大家帮帮我呀。
x=input('请输入一个数组:\n')
(之后在命令行输入:)
[2009 10 26]
可能直接用:
x=input('输入元素:','s');
MATLAB帮助文件:
input:
Request user input
collapse all in page
Syntax
x = input(prompt)
example
str = input(prompt,'s')
example
If the user presses the Return key without entering anything, then input returns an empty matrix.
If the user enters an invalid expression at the prompt, then MATLAB® displays the relevant error message, and then redisplays the prompt.
Description
example
x = input(prompt) displays the text in prompt and waits for the user to input a value and press the Return key. The user can enter expressions, like pi/4 or rand(3), and can use variables in the workspace.
example
str =&n