input set of vectors

조회 수: 18 (최근 30일)
Minh Nguyen
Minh Nguyen 2021년 1월 2일
댓글: Walter Roberson 2021년 1월 2일
Write a program to input any number of vector in R^n
m=input ('number of vectors: ');
n=input ('size of vector; ');
clc
for i=1:m
for j=1:n
vector=input('enter the elements')
disp(vector)
end
end
Here is my code but it was wrong.
  댓글 수: 2
KALYAN ACHARJYA
KALYAN ACHARJYA 2021년 1월 2일
Please refer MATLAB Onramp
m=input('Number of Vectors: ');
n=input('Size of Vector: ');
vector=zeros(1,n);
for i=1:m
fprintf('The Vector: %d ...\n',i);
for j=1:n
vector(j)=input('Enter the Elements: ');
end
fprintf('\n The Vector:%d is',i);
disp(vector);
end
Walter Roberson
Walter Roberson 2021년 1월 2일
Caution: the user can enter 0, 1, 2 or more values in response to input. It would be a good idea to verify that you have exactly one numeric value before you store the element.

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

답변 (0개)

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by