How to specify size of row and column vector
Show older comments
*If we have a row vector A
and a column vector B
How do we specify the size for both vectors ?*
Accepted Answer
More Answers (2)
Wayne King
on 27 Sep 2013
How do you find the size, or how do you specify?
To find the size, simply use length()
A = randn(100,1);
length(A)
If you want to pre-allocate, then you can use zeros()
A = zeros(100,1);
If this is not answering your question, can you please elaborate and give an example.
Image Analyst
on 28 Sep 2013
Try this:
% Ask user for a number.
defaultValue = {'7'; '5'};
titleBar = 'Enter a value';
userPrompt = {'Enter the row vector width '; 'Enter the column vector height '};
caUserInput = inputdlg(userPrompt, titleBar, 2, defaultValue);
if isempty(caUserInput),return,end; % Bail out if they clicked Cancel.
rowWidth = str2double(caUserInput{1})
columnHeight = str2double(caUserInput{2})
% Make the row vector and column vector with some arbitrary values.
rowVector = zeros(1, rowWidth)
columnVector = ones(columnHeight, 1)
Categories
Find more on Creating and Concatenating Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!