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

133 vues (au cours des 30 derniers jours)
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] ?

Réponse acceptée

KSSV
KSSV le 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 commentaires
Sithum Nanayakkara
Sithum Nanayakkara le 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 le 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

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by