fprintf ('Invalid Number!! number has to be GREATER THAN 4 and LESS THAN 11\n')
n=input('Enter a number between 5 and 10: ');
end
A=randi([0 20],1,n);
B=randi([0 10]',1,n)';
I have made an Array A as first row
and Array B as first Column
I just dont know how to create an array C with the numbers from array A and B. I googled a bunch and I cant find a noob friendly solution. I am in comp apps 1 so im sure the solution is simple.
You can concatenate variables with the [ ] notation. E.g.,
[x,y] concatenates the variables horizontally
[x;y] concatenates the variables vertically
You can transpose a vector from row to column (or vice-versa) with the .' operator, or just ' if you know the variable is real. E.g., if x is a real row vector, then x' will be a real column vector.
You can multiply two variables element-wise with the .* operator. If one of these is a row and the other one is a column, then the result will be a 2D matrix with the element-wise products as the elements.
See if you can experiment and work with the above to come up with the parts you want, and then see if you can use the [ ] notation to put them all together into the final matrix you want. Come back and ask more questions when you have trouble with your progress.
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
5 Comments
Direct link to this comment
https://fr.mathworks.com/matlabcentral/answers/645113-transfer-array-into-another-array#comment_1127323
Direct link to this comment
https://fr.mathworks.com/matlabcentral/answers/645113-transfer-array-into-another-array#comment_1127323
Direct link to this comment
https://fr.mathworks.com/matlabcentral/answers/645113-transfer-array-into-another-array#comment_1127328
Direct link to this comment
https://fr.mathworks.com/matlabcentral/answers/645113-transfer-array-into-another-array#comment_1127328
Direct link to this comment
https://fr.mathworks.com/matlabcentral/answers/645113-transfer-array-into-another-array#comment_1127333
Direct link to this comment
https://fr.mathworks.com/matlabcentral/answers/645113-transfer-array-into-another-array#comment_1127333
Direct link to this comment
https://fr.mathworks.com/matlabcentral/answers/645113-transfer-array-into-another-array#comment_1127338
Direct link to this comment
https://fr.mathworks.com/matlabcentral/answers/645113-transfer-array-into-another-array#comment_1127338
Direct link to this comment
https://fr.mathworks.com/matlabcentral/answers/645113-transfer-array-into-another-array#comment_1127393
Direct link to this comment
https://fr.mathworks.com/matlabcentral/answers/645113-transfer-array-into-another-array#comment_1127393
Sign in to comment.