I m trying to create 16x16 matrix with variable terms, but it says Error using ==> vertcat CAT arguments dimensions are not consistent.

A=[1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
ps (1-ps-pf) 0 0 0 pf 0 0 0 0 0 0 0 0 0 0
0 ps (1-ps-pf) 0 0 0 pf 0 0 0 0 0 0 0 0 0
0 0 ps (1-ps-pf) 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 (1-ps-pf) 0 0 0 pf 0 0 0 0 0 0 0
ps 0 0 0 0 (1-ps-pf) 0 0 0 pf 0 0 0 0 0 0
0 ps 0 0 0 0 (1-ps-pf) 0 0 0 pf 0 0 0 0 0
0 0 ps 0 0 0 0 (1-ps-pf) 0 0 0 pf 0 0 0 0
0 0 0 0 0 0 0 0 (1-ps-pf) 0 0 0 pf 0 0 0
ps 0 0 0 0 0 0 0 0 (1-ps-pf) 0 0 0 pf 0 0
0 ps 0 0 0 0 0 0 0 0 (1-ps-pf) 0 0 0 pf 0
0 0 ps 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 (1-ps-pf) 0 0
(ps+pf) 0 0 0 0 0 0 0 0 0 0 0 0 0 (1-ps-pf) 0
0 (ps+pf) 0 0 0 0 0 0 0 0 0 0 0 0 0 (1-ps-pf)
0 0 (ps+pf) 0 0 0 0 0 0 0 0 0 0 0 0 0];

3 Comments

The matrix required is:
A=[1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0; ps (1-ps-pf) 0 0 0 pf 0 0 0 0 0 0 0 0 0 0; 0 ps (1-ps-pf) 0 0 0 pf 0 0 0 0 0 0 0 0 0; 0 0 ps (1-ps-pf) 0 0 0 0 0 0 0 0 0 0 0 0; 0 0 0 0 (1-ps-pf) 0 0 0 pf 0 0 0 0 0 0 0; ps 0 0 0 0 (1-ps-pf) 0 0 0 pf 0 0 0 0 0 0; 0 ps 0 0 0 0 (1-ps-pf) 0 0 0 pf 0 0 0 0 0; 0 0 ps 0 0 0 0 (1-ps-pf) 0 0 0 pf 0 0 0 0; 0 0 0 0 0 0 0 0 (1-ps-pf) 0 0 0 pf 0 0 0; ps 0 0 0 0 0 0 0 0 (1-ps-pf) 0 0 0 pf 0 0; 0 ps 0 0 0 0 0 0 0 0 (1-ps-pf) 0 0 0 pf 0; 0 0 ps 0 0 0 0 0 0 0 0 0 0 0 0 0; 0 0 0 0 0 0 0 0 0 0 0 0 0 (1-ps-pf) 0 0; (ps+pf) 0 0 0 0 0 0 0 0 0 0 0 0 0 (1-ps-pf) 0; 0 (ps+pf) 0 0 0 0 0 0 0 0 0 0 0 0 0 (1-ps-pf); 0 0 (ps+pf) 0 0 0 0 0 0 0 0 0 0 0 0 0];
but it generates vertcat error saying:
??? Error using ==> vertcat CAT arguments dimensions are not consistent.
Isn't this the same code as before? Like I said below, don't have ps or pf be arrays.
But the matrix has to be created in terms of these variables. These variables cant be assigned constant. The values of ps and pf vary b/w 0to 1 with an interval 0.001 and ps+pf=p (third variable).

Sign in to comment.

Answers (1)

I assigned some scalar values for ps and pf and it ran fine. You must have at least one of them be an array. What are the values for ps and pf? Put a breakpoint on that line to be sure.

Categories

Asked:

on 19 Feb 2013

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!