how to generate complex matrix with variable diamension???
Show older comments
Lets say there is a matrix A whose diamension is m x n, where n is varies with respect to another variable lets say l.
this is the case the how we generate a complex matrix.
Accepted Answer
More Answers (1)
John D'Errico
on 29 Nov 2018
0 votes
A very confusing question. Are you asking how to generate a matrix with complex elements? MATLAB automatically uses complex form for double and single precision input when appropriate. So that question would be simply answered if it is indeed what you mean.
Is your question really how to create a matrix with a complicated shape? So one where each row of the matrix may have a different number of columns? You cannot do that for a standard matrix in MATLAB. All arrays are rectangular. So every row has the same number of columns.
Having said that, you can of course use a cell array to store each row. Since any cell can contain anything, there is no problem at all. You just need to learn to work with cell arrays, not a difficult thing. You can also llearn to work with structs, tools that again can contain anything you want to put into them. Finally, you canjust create a flat rectangular array,filled with NaNs, for example. Then store your data in the first elements of each row, using as many as you need. When you use the data for that row, you just need to extract only that which contains usable data.
Categories
Find more on Logical 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!