what do you mean by umat?
6 views (last 30 days)
Show older comments
Uncertain matrix with 0 rows, 0 columns, and no uncertain blocks.
Type "ans.NominalValue" to see the nominal value, "get(ans)" to see all properties, and "ans.Uncertainty" to interact with the uncertain elements.
2 Comments
Accepted Answer
Guillaume
on 5 Feb 2015
Edited: Guillaume
on 5 Feb 2015
the root of your problem is that your for loop body never gets executed because Blocks = 1 (so you're asking the loop to go from 1 to 0). As a result, the variable umat never gets created and when your code reaches the line
display(umat)
it actually calls the function umat of one of matlab's toolbox. This is this function that raises the error you see (I assume, I don't have that toolbox).
One obvious way to prevent this problem is to have the following code just before the loop:
if Blocks < 2
error("Blocks is less that 2. Aborting script. Review your inputs");
end
That obviously won't resolve the underlying problem that one of your input or calculation prior to that is not what it should. As your code is written, N would need to be at least twice the value of M for Blocks to be at least 2.
Also, are you aware that you're changing the value of your input N within the code. N starts as 200 and is modified to 128. I don't know if it's intended or not. I would avoid reusing the same variable name for different purpose. It can only lead to bugs in the long term.
Finally, I would avoid using length. numel for vectors or size for matrices is better. length can be the number of rows or columns or pages, etc. depending on which dimension is greater. It's very rare you don't care about which dimension you want the size of.
0 Comments
More Answers (0)
See Also
Categories
Find more on Sparse Matrices 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!