Getting an error : In an assignment A(:) = B, the number of elements in A and B must be the same.
2 ビュー (過去 30 日間)
古いコメントを表示
Arun Chellappan
2017 年 12 月 11 日
コメント済み: Arun Chellappan
2017 年 12 月 12 日
% Load the converted TDMS file into matlab
load('TEST_2017_12_04_11_25_51.mat')
Force=ConvertedData.Data.MeasuredData(15).Data; % Input Force values into F
F=Force.';% Transpose matrix for Force for RBF calculation
dis=ConvertedData.Data.MeasuredData(9).Data ; % Input Displacement values into dis
N=1;
for m=1:length(F) % Find Number of displacement per Force and assign it to Dis
for n=1:(length(dis)/length(F))
Dis(m,n)=dis(N);
N=N+1;;
end
end
DIS=Dis.'; % Transpose matrix for mean displacement calculation
mean_dis=mean(DIS); % Calculate mean dispalcement value
%Input first sensor position and bearing position
% Fir_sen=input(' Input the First sensor position');
%
% Bear_pos=input(' Input the bearing position');
%input calculated radial force values solve equations
val=zeros(1,708);
j=1;
for m=1:(length(F))
a=F(m);
syms RBF;
syms BSBF;
% solve the equations and find radial bearing load
% F= applied load. RBF= roller bearing force .
% BSBF= back support bearing force
eqn1=(331.5*a)-(RBF*231.5);
eqn2=(BSBF * 231.5)+(100*a);
sol=solve(eqn1,eqn2);
val(j)=(double (sol.RBF)); % * _*** This statement is the problem ***_*
j=j+1;
end
disp('New calculated radial force values');
disp(valueofRBF);
why am i getting this error ? 'In an assignment A(:) = B, the number of elements in A and B must be the same' ?
4 件のコメント
Karan Gill
2017 年 12 月 11 日
編集済み: Karan Gill
2017 年 12 月 11 日
I think the reason Adam posted that comment because using the debugger will actually let you check the values in question. Further, also because you did not post the actual error. So we don't know where the error occurs. No one will realize you added a comment for the line in question.
採用された回答
David Goodmanson
2017 年 12 月 11 日
編集済み: David Goodmanson
2017 年 12 月 11 日
Hi Arun,
Have you checked the value of RBF? I think it's quite likely that since you have supplied the value of 'a', you are attempting to solve three equations in the two unknowns RBF and BSBF. Not a great idea. You might get a result like " RBF = 0×1 empty double column vector ". (It's true that the third equation is redundant, since it is a consequence of the other two. So you should be able to "solve" all three of them at once. But it doesn't always work out that way in practice). Anyway, if this does turn out to be the the problem, why use syms at all? Algebra works.
RBF = a*331.5/231.5; BSBF = a - RBF;
4 件のコメント
David Goodmanson
2017 年 12 月 11 日
That's interesting, because when I supply a value for 'a', make a simple val array and try to solve the three equations I get that exact error message, and reverting to just two equations (as you did in the question) works. Different results for you, so the real answer must be elsewhere. What is the value of sol.RBF when the error occurs?
その他の回答 (1 件)
Walter Roberson
2017 年 12 月 11 日
You use solve(l, which requests that all closed form solutions be found, and in the case of polynomials that all roots be found. But your code assumes that exactly one solution is found. You should examine sol.RBF to see how large it is. Perhaps you could use eliminate some of the possible solutions by adding assumptions to the variables such as
syms RBF positive
参考
カテゴリ
Help Center および File Exchange で Number Theory についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!