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);

采纳的回答

Walter Roberson
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 个评论
Kevin Krone
Kevin Krone 2019-4-23
Now nothing is being displayed
syms y1
syms t1
syms y2
syms t2
syms y3
syms t3
syms y4
syms t4
syms y5
syms t5
syms t6
syms y7
syms t7
syms y8
syms t8
syms y9
syms t9
syms 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 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 10378.6 10378.6 -10378.6 20757.24];
B = [y1; t1; y2; t2; y3; t3; y4; t4; y5; t5; t6; y7; t7; y8; t8; y9; t9;t10];
X = [150;0; 0;0; 0;0; 0;0; 0;0; 0; 0;0; 0;0; 0;0; 0];
solve(A.*X==B);
Walter Roberson
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!

Translated by