Clear Filters
Clear Filters

How do i make a matrix like this

3 views (last 30 days)
I'm trying to make a matrix with two columns. The second column is from .5 to 20 with .1 increments and i want the first column to have .5 for as many rows the second column gives, but I also want this to happen for .6, .7, .8, .9, 1, 1.1,... and all the way up to 20 with .1 increments in the same matrix.
i put a picture of a small portion for what i'm talking about.

Accepted Answer

Walter Roberson
Walter Roberson on 29 Apr 2018
[C1, C2] = ndgrid(0.5:.1:20);
matrix = [C1(:), C2(:)];
  3 Comments
KALYAN ACHARJYA
KALYAN ACHARJYA on 29 Apr 2018
Edited: KALYAN ACHARJYA on 29 Apr 2018
Are you getting the result as per your requirement? The answer is interesting, that's why I have checked it, I got the result as follows-
Walter Roberson
Walter Roberson on 29 Apr 2018
You can replace ndgrid() with meshgrid() to get the values in the other order.

Sign in to comment.

More Answers (0)

Categories

Find more on Matrices and Arrays in Help Center and File Exchange

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!