Dimensions of arrays being concatenated are not consistent

1 view (last 30 days)
I am following the guide for a problem that involves matrices and the goal of this code is to be able to input values simply by using a keyboard. However, I keep getting this error code that I listed in the title even though I am following the guide exactly. Any and all help is greatly appreciated.
R1 = ('Input the value of R1: ');
R2 = ('Input the value of R2: ');
R3 = ('Input the value of R3: ');
R4 = ('Input the value of R4: ');
R5 = ('Input the value of R5: ');
V = ('Input the value of voltage, V: ');
coef = [(R2 + R4), -R2, -R4;
-R2, (R1 + R2 + R3), (-R3);
-R4, -R3, (R3 +R4 + R5)];
result = [V; 0; 0];
I = inv(coef)*result
Error using vertcat
Dimensions of arrays being concatenated are not consistent.
Error in Mini_Project_3_Part4 (line 10)
result = [V; 0; 0]

Accepted Answer

KSSV
KSSV on 3 Nov 2020
R1 = input('Input the value of R1: ');
R2 = input('Input the value of R2: ');
R3 = input('Input the value of R3: ');
R4 = input('Input the value of R4: ');
R5 = input('Input the value of R5: ');
V = input('Input the value of voltage, V: ');
coef = [(R2 + R4), -R2, -R4;
-R2, (R1 + R2 + R3), (-R3);
-R4, -R3, (R3 +R4 + R5)];
result = [V; 0; 0];
I = inv(coef)*result
  2 Comments
Stephen23
Stephen23 on 3 Nov 2020
Edited: Stephen23 on 3 Nov 2020
Rather than this
inv(coef)*result
prefer the more efficient and numerically much more stable
coef\result
Corey Kado
Corey Kado on 3 Nov 2020
Thank you very much I didn't even realize that the input functions were missing.

Sign in to comment.

More Answers (0)

Categories

Find more on Creating and Concatenating Matrices in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!