How to assign the size of an array stored in a variable to the "end value of another array stored in a different variable" ?

1 view (last 30 days)
For example,
b=[1:5];
I want to assign the size of 'b' which is 5 in this case to another variable 'a' using the linspace function,
Example:
b=[1:5];
a=linspace(1,1,size(b))
Basically I want to plot these two arrays together. Since a is scalar, the plot doesn't work. But if a=[1,1,1,1,1], then everything works fine. My program has changing values of 'b' throughout the code and I would like to instruct MATLAB find the size of 'b' and assign it to 'a'
Please let me know if there is a way to do it,
Sujith

Accepted Answer

Walter Roberson
Walter Roberson on 16 Mar 2014
length(b) or size(b,2)

More Answers (0)

Categories

Find more on Multidimensional Arrays 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!