my first variable (y1) is coming us as undefined
1 次查看(过去 30 天)
显示 更早的评论
var y1
var t1
var y2
var t2
var y3
var t3
var y4
var t4
var y5
var t5
var t6
var y7
var t7
var y8
var t8
var y9
var t9
var t10
A = [4224.3 7392.5 -4224.3 7392.5 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0;
7392.5 17249.14 -7392.5 8624.57 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0;
-4224.3 -7392.5 8448.6 0 -4224.3 7392.5 0 0 0 0 0 0 0 0 0 0 0 0 0 0;
7392.5 8624.57 0 34498.28 -7392.5 8624.57 0 0 0 0 0 0 0 0 0 0 0 0 0 0;
0 0 -4224.3 -7392.5 8448.6 0 4224.3 7392.5 0 0 0 0 0 0 0 0 0 0 0 0;
0 0 7392.5 8624.57 0 34498.28 -7392.5 8624.57 0 0 0 0 0 0 0 0 0 0 0 0;
0 0 0 0 -4224.3 -7392.5 447045.3176 158665.3816 -442821.0176 166057.8816 0 0 0 0 0 0 0 0 0 0;
0 0 0 0 7392.5 8624.57 158665.3816 100278.081 -166057.8816 41514.47 0 0 0 0 0 0 0 0 0 0;
0 0 0 0 0 0 -442821.0176 -166057.8816 608878.9 0 -442821.0176 166057.8816 0 0 0 0 0 0 0 0;
0 0 0 0 0 0 166057.8816 41514.47 0 166057.822 -166057.8816 41514.47 0 0 0 0 0 0 0 0;
0 0 0 0 0 0 0 0 -442821.0176 -166057.8816 453199.6376 -155679.2816 -6919.08 10378.6 0 0 0 0 0 0;
0 0 0 0 0 0 0 0 166057.8816 41514.47 -155679.2816 103786.181 -10378.6 10378.62 0 0 0 0 0 0;
0 0 0 0 0 0 0 0 0 0 -6919.08 -10378.6 17297.68 0 -6919.08 10378.6 0 0 0 0;
0 0 0 0 0 0 0 0 0 0 10387.6 10378.6 0 41514.48 -10378.6 10378.6 0 0 0 0;
0 0 0 0 0 0 0 0 0 0 0 0 -6919.08 -10378.6 17297.68 0 -6919.08 10378.6 0 0;
0 0 0 0 0 0 0 0 0 0 0 0 10378.6 10378.62 0 41514.48 -10378.6 10378.6 0 0;
0 0 0 0 0 0 0 0 0 0 0 0 0 0 -6919.08 -10378.6 17297.68 0 -6919.08 10378.6;
0 0 0 0 0 0 0 0 0 0 0 0 0 0 10378.6 10378.62 0 41514.48 -10378.6 10378.6;
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -6919.08 -10378.6 6919.08 -10378.6;
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10378.6 10378.6 -10378.6 20757.24];
B = [ y1;t1; y2;t2; y3;t3; y4;t4; y5;t5; 0;t6; y7;t7; y8;t8; y9;t9; 0;t10];
X = [150;0; 0;0; 0;0; 0;0; 0;0; 300;0; 0;0; 0;0; 0;0; 150;0];
solve(X.*A==B);
0 个评论
采纳的回答
Walter Roberson
2019-4-23
var y1
uses "Command/function duality", and means the same thing as
var( 'y1' )
which requestions that the variance be calculated of the vector of values ['y', '1'] . Because there is no semi-colon at the end of the line, the result of the variance calculation would be displayed. No symbolic variable would be defined.
Perhaps you wanted to use syms instead of var
2 个评论
Walter Roberson
2019-4-23
Your A is 18 * 20. Your X is 18 x 1. In releases up to R2016a, A.*X would be invalid. In R2016b and later, A.*X is treated similar to bsxfun(@times, A, X), which is effectively the same as A.*repmat(X, 1, size(A,2)) . The result will be the same size as A, which is 18*20 . You then want to solve for an 18*20 matrix to equal an 18 x 1 matrix
Typically when people use notations with A, x, and b, they are trying to solve A*x == b with known A and known b, and x having as many rows as A has, and as many columns as b has. Notice this is the * operator, not the .* operator. The * operator is matrix multiplication.
Perhaps what you want is
temp = num2cell( A\X );
[y1, t1, y2, t2, y3, t3, y4, t4, y5, t5, t6, y7, t7, y8, t8, y9, t9, t10] = deal(temp{:});
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!