Hauptinhalt

Create Arrays by Assignment

Arrays can be created by direct assignment. As with other MATLAB® classes, there is no need to preallocate the variable first. Simply assign elements – all resizing is performed automatically.

For instance, an equivalent construction to

a = ureal('a',4); 
b = ureal('b',2); 
M = stack(1,[a b 1],[-a -b 4+a],[4 5 6],[a 0 0]); 
is 
Mequiv(1,1,1) = a; 
Mequiv(1,2,1) = b; 
Mequiv(1,3,1) = 1; 
Mequiv(1,:,4) = [a 0 0]; 
Mequiv(1,:,2:3) = stack(1,[-a -b 4+a],[4 5 6]); 

The easiest manner for you to verify that the results are the same is to subtract and simplify,

d5 = simplify(M-Mequiv); 
max(abs(d5(:))) 
ans = 
     0