I am working on a script to take user input for a number, then create an array with 5 columns from 1 to said number. I am having trouble changing the array from a inputX1 matrix to an inputX5 could someone help me please. I tried to use the reshape function but since the input can be a nonmultiple of 5 the function doesn't work all the time. Here is the code
clear
name=input('Enter name:','s');
number=input('Enter a whole number between 1 and 100:');
while number<1 || number>100 || round(number)~=number
display('Not a valid number please try again')
number=input('Enter a whole number between 1 and 100:')
end
array=[1:number];
entryposition=0;
disp('Thank you!')
disp(name)
disp(array')
4 Comments
Direct link to this comment
https://in.mathworks.com/matlabcentral/answers/502688-changing-array-size-of-user-input-data#comment_791463
Direct link to this comment
https://in.mathworks.com/matlabcentral/answers/502688-changing-array-size-of-user-input-data#comment_791463
Direct link to this comment
https://in.mathworks.com/matlabcentral/answers/502688-changing-array-size-of-user-input-data#comment_791467
Direct link to this comment
https://in.mathworks.com/matlabcentral/answers/502688-changing-array-size-of-user-input-data#comment_791467
Direct link to this comment
https://in.mathworks.com/matlabcentral/answers/502688-changing-array-size-of-user-input-data#comment_791474
Direct link to this comment
https://in.mathworks.com/matlabcentral/answers/502688-changing-array-size-of-user-input-data#comment_791474
Direct link to this comment
https://in.mathworks.com/matlabcentral/answers/502688-changing-array-size-of-user-input-data#comment_791478
Direct link to this comment
https://in.mathworks.com/matlabcentral/answers/502688-changing-array-size-of-user-input-data#comment_791478
Sign in to comment.