MATLAB Answers

Changing Variable in matrix

9 views (last 30 days)
Yoga Arviansyah
Yoga Arviansyah on 30 Oct 2019
Answered: Tianhao Zhang on 30 Oct 2019
How to change variable into number in matrix, for example I have A=[a b c]: Then i declare a = 1 b = 2 c = 3 So matrix will be A = [1 2 3]
Thank you

  0 Comments

Sign in to comment.

Answers (2)

Bob Nbob
Bob Nbob on 30 Oct 2019
Why are you originally defining A as A = [a b c]? This isn't very common or efficient matlab usage. I would suggest starting with A = [1 2 3] and adjusting the values as needed. As for the change, see below.
% Defining A
A = [1 2 3];
% Changing A to 2 4 6
A = [2 4 6];
% or
A(1) = 2;
A(2) = 4;
A(3) = 6;

  0 Comments

Sign in to comment.


Tianhao Zhang
Tianhao Zhang on 30 Oct 2019
Like this?
a = 1;
b = 2;
c = 3;
A = [a b c]

  0 Comments

Sign in to comment.