what's the program mistake?

clear all
clc;
syms a b c
w=zeros(3,1);
w(1,1)=3*a+b;
w(2,1)=b+2;
w(3,1)=c-a;
disp(w)
b=3;
disp(w)

2 Comments

why do you need
syms a b c
excuse me check the question again

Sign in to comment.

 Accepted Answer

w = sym(zeros(3,1))
You preallocated w as a numeric type and then tried to stuff a sym into it. If you preallocate w as a symbolic, it works as expected.

3 Comments

why isn't the program replace b qauntity in w matrix in second step?
You would need to subs-stitude it in
subs(w,b,3)
subs(w,[a b c],[a 3 c]) now works,thank you so much

Sign in to comment.

More Answers (0)

Asked:

MA
on 3 Jun 2014

Commented:

MA
on 3 Jun 2014

Community Treasure Hunt

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

Start Hunting!