MATLAB Answers

Koen
0

how to create on an efficient way zeros in a symbolic matrix?

Asked by Koen
on 12 Nov 2014
Latest activity Edited by MA
on 12 Nov 2014
hey,
I want to create a matrix/array A with size(n,2) (for arbitrary n) such that
A(:,1) = zeros(n,1)
A([1:n-1],2) = 0;
A(n,2) = x (with x a symbolic, in matlab written as 'sym x' )
How do I do it on a efficient way?

  0 Comments

Sign in to comment.

1 Answer

Answer by MA
on 12 Nov 2014
Edited by MA
on 12 Nov 2014
 Accepted Answer

syms x
n=4;
A=sym(zeros(n,2));
A(:,1) = zeros(n,1);
A([1:n-1],2) = 0;
A(n,2) = x;
A

  0 Comments

Sign in to comment.