Info

This question is closed. Reopen it to edit or answer.

Create matrices with stored variables and multiply by vector with variables too.

1 view (last 30 days)
Hi, How can I create an intermediate matrix with previously stored variables and use it to multiply by a column vector? I make some mistake with the lines below:
Smatrix = [Sb11 Sb12 Sb13;
Sb21 Sb22 Sb23;
Sb31 Sb32 Sb33];
Stot = [Sx; Sy; Sz];
sXYZ = Smatrix * Stot;
The variable Sb11, for instance is defined by: (cos(theta)+r*1/3) and 'r1 was previously stored with this command:
%prompt = 'Insert the r value: ';
%r = input(prompt)
For each variable there is an equation similar with nine variables defined like the 'r' above. Thanks by any suggestion.

Answers (1)

the cyclist
the cyclist on 18 Jul 2015
From what you have posted, I can't diagnose a problem. You seem to be multiplying a 3x3 matrix and a 3x1 vector, which of course should be fine.
I have two suggestions.
First, if you do not know how to use debugging, then you should learn that. You can put a breakpoint in the code, halt execution temporarily, and see the sizes of each variable, which may expose something unexpected.
Second, perhaps you could post code in which you actually assign values to each of the variable above, such that you create a self-contained piece of code that will actually run up until the error. That way, we can run the code and see the error ourselves.

Community Treasure Hunt

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

Start Hunting!