Variable x must be of size [2 1]. It is currently of size [2 2]. Check where the variable is assigned a value.

143 Ansichten (letzte 30 Tage)
All lines except the 8th comes up as correct but line 8 comes up as incorrect and states the reason "Variable x must be of size [2 1]. It is currently of size [2 2]. Check where the variable is assigned a value."
How can i change this code to get a [2 1] matrix instead of [2 2] ?

Akzeptierte Antwort

KSSV
KSSV am 18 Mai 2020
A = [1 2 4 5 7 ; 9 2 1 4 13] ;
B = [-11 2 ; 3 -1 ; 2 0; 5 11 ; -21 1];
C = A*B ;
D = B*A ;
s = det(C) ;
t = det(D) ;
x = inv(C).*[8 -1].^t ;
  10 Kommentare
Sithum Nanayakkara
Sithum Nanayakkara am 25 Mai 2020
Here :
D = [-3,-18,1,-47,3;2,4,2,11,1;1,4,3,10,8;1,32,4,69,5;7,-40,5,-101,-1];
b = [11;3;7;-17;1];
x = linsolve(D,b) ;
KSSV
KSSV am 25 Mai 2020
clc; clear all ;
D = [-3 -18 1 -47 3 ;
2 4 2 11 1 ;
1 4 3 10 8 ;
1 32 4 69 5 ;
7 -40 5 -101 -1] ;
b = [11 ; 3 ;7 ;-17 ;1] ;
x = D\b

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by