How to declare above type of variable in MATLAB?
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Stephen23
2020-9-30
"How can I declare the above type of variable before hand and fill up the numbers in loop?"
n = cell(1,9);
for k = 1:9
n{k} = [val1,val2];
end
更多回答(1 个)
Ameer Hamza
2020-9-30
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));
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Model Upgrades 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!