Getting an error : In an assignment A(:) = B, the number of elements in A and B must be the same.
    2 views (last 30 days)
  
       Show older comments
    
    Arun Chellappan
 on 11 Dec 2017
  
    
    
    
    
    Commented: Arun Chellappan
 on 12 Dec 2017
            % 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 Comments
  Karan Gill
    
 on 11 Dec 2017
				
      Edited: Karan Gill
    
 on 11 Dec 2017
  
			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.
Accepted Answer
  David Goodmanson
      
      
 on 11 Dec 2017
        
      Edited: David Goodmanson
      
      
 on 11 Dec 2017
  
      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 Comments
  David Goodmanson
      
      
 on 11 Dec 2017
				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?
More Answers (1)
  Walter Roberson
      
      
 on 11 Dec 2017
        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
See Also
Categories
				Find more on Number Theory in Help Center and File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



