How to create an array with user inputs?
36 次查看(过去 30 天)
显示 更早的评论
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!
0 个评论
回答(2 个)
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
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
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!