필터 지우기
필터 지우기

How to create an array with user inputs?

조회 수: 10 (최근 30일)
Soeun Lee
Soeun Lee 2021년 8월 5일
답변: d bhaskar 2023년 2월 24일
Hello, I am trying to create an array with user inputs. For example, if the user types 3, 5, 7, the array comes out to be [3,5,7]. How can I do this? Thanks in advance for your help!

답변 (2개)

Sulaymon Eshkabilov
Sulaymon Eshkabilov 2021년 8월 5일
You can consider using input() prompt. See this doc with examples: https://www.mathworks.com/help/matlab/ref/input.html?s_tid=srchtitle
  댓글 수: 1
Soeun Lee
Soeun Lee 2021년 8월 5일
Thanks for your answer. I am using the input() prompt, but the only problem is I don't know how to put the user inputs into an array. Any ideas?

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


d bhaskar
d bhaskar 2023년 2월 24일
clc
clear all
n=2; m=2;
for i=1:n
for j=1:m
fprintf('Enter a(%d,%d)=',i,j);
a(i,j)=input('');
end
end

카테고리

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

제품

Community Treasure Hunt

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

Start Hunting!

Translated by