i am trying to run a series of equations by calling certain data points from my matrix over a series of combinations. I am essentially comparing each data set against the others, one at a time, over a series of different errors (the errors are the psivct array).
i am getting a "subscripted assignment dimension mismatch" error for the final line of my code and i don't know what to do about it....? I have done my best to comment out my code for clarity...
it works fine when i am only comparing two sets, but when i add the third, i get this error. Any insight?
Thanks again in advance for any help :)
datamatrix=[674 0 6049 46489;760 180 90735 120980; 650 0 12500 61000]; %data points velocity,
heading, x location, y location
psivct=[-90, -45, 0, 45, 90];%degrees degrees of error
psidot=3; %degrees/sec rate of error change
d=500; %distance apart for a problem, in feet
Nr_AC=3; %number of aircrafts in sector
for c1 = 1:size(psivct,2)
psi1=psivct(c1); %for loop to run through array of blunder errors
for c2=1:Nr_AC-1; %for loop to account for all pairs and avoid same pairs twice
for c3=c2+1:Nr_AC; %for loop to help avoid account for hte same pairs twice
k1=datamatrix(c2,1).*cosd(datamatrix(c2,2)+psi1)-datamatrix(c2,1)*cosd(datamatrix(c3,2));
k2=((datamatrix(c2,1)/psidot).*(sind(datamatrix(c2,2)+psi1)-sind(datamatrix(c2,2))))
cosd(datamatrix(c2,2)+psi1)*datamatrix(c2,1).*(psi1./psidot)+datamatrix(c2,3)-datamatrix(c3,3);
k3=datamatrix(c2,1).*sind(datamatrix(c2,2)+psi1)-datamatrix((c3),1)*sind(datamatrix((c3),2));
k4=(datamatrix(c2,1)/psidot)*(cosd(datamatrix(c2,2))-cosd(datamatrix(c2,2)+psi1))
sind(datamatrix(c2,2)+psi1)*datamatrix(c2,1).*(psi1./psidot)+datamatrix(c2,4)-datamatrix(c3,4);
k5=k1.^2+k3.^2; %"a" in the polynomial
k6=2*(k1.*k2+k3.*k4); %"b" in the polynomial
k7=k3.^2+k4.^2-500; %"c" in the polynomial
p = [k5 k6 k7]; % creating hte polynomial
r = roots(p); %solving for roots
rr(:,c1,c2,c3)=real(r)/60 %getting real answers
end;
end;
end;
ris empty whenc1=3, c2=1, c3=3.ris empty becausep=[0 0 -500], it has no roots. From here, you have to take on the problem. Also, this is basic debugging. You need to learn this to solve your problems more efficiently. - Autonomous