Hi there, I need to create a script in which I ask the user to input a vector of n elements. In this script, n is already inserted by the user previously and now my objective is to create this vector (nx1) in which each element is a number inserted through an input function by the user. Thanks in advance.

 채택된 답변

KALYAN ACHARJYA
KALYAN ACHARJYA 2019년 9월 25일
편집: KALYAN ACHARJYA 2019년 9월 26일
function result=test( )
n=input('Enter the vector length: ');
result=zeros(1,n);
for i=1:n
result(i)=input('Enter the vector Element');
end
disp('The Entered vector is: ')
disp(result)
end
Please try to understand the code and make changes as per requirements (if needed). Ultimate way of learning is "doing it yourself".

추가 답변 (0개)

카테고리

도움말 센터 및 File Exchange에서 Simulink Check에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by