How to declare above type of variable in MATLAB?
Show older comments
n = {[1,2] [1,6] [2,3] [2,6] [3,4] [3,6] [4,5] [4,6] [5,6]}
How to declare above type of variable in MATLAB?
4 Comments
Ameer Hamza
on 29 Sep 2020
This is already a valid MATLAB syntax. What is the issue here?
KSSV
on 29 Sep 2020
n is of class type cell. You can them using flower braces, n{1}, n{2} etc....you can convert it to a matrix using cell2mat.
Gaurab Raj Neupane
on 30 Sep 2020
Gaurab Raj Neupane
on 30 Sep 2020
Edited: Gaurab Raj Neupane
on 30 Sep 2020
Accepted Answer
More Answers (1)
Ameer Hamza
on 30 Sep 2020
An alternative is to use mat2cell() like this
x = [1 2 3 4 5 6 7 8]; % example values
C = mat2cell(x, 1, 2*ones(1,numel(x)/2));
Categories
Find more on Matrix Indexing 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!