Azzera filtri
Azzera filtri

Hi!.Can anyone please help me how to get rid of this errors.I herby attach my code and the errors.

1 visualizzazione (ultimi 30 giorni)
function [xfar_in,yfar_in] = fartheta(y_veh, x_veh)
% c=0.0100;
% error_in=0;
% amplitude=1;
% xfar_in=zeros(2,1);
% yfar_in=zeros(2,1);
% xin_new=zeros(2,1);
% yin_new=zeros(2,1);
% slope_in=zeros(2,1);
% slope_curve_in=zeros(2,1);
x_save = zeros(2,1);
y_save = zeros(2,1);
% coder.varsize('x_save',[1, 2 * length(x_veh)]);
% coder.varsize('y_save',[1, 2 * length(y_veh)]);
% error_in = 0.001;
% xin_new = x_veh;
% yin_new = y_veh;
for i = 1:length(x_veh)
xin_new = x_veh(i);
yin_new = y_veh(i);
error_in = 0.001;
while error_in>=0
xin_new = xin_new + 0.01;
yin_new = 1*sin(2*pi*xin_new/25);
slope_in = (yin_new-y_veh)/(xin_new-x_veh);
slope_curve_in = (1*2*pi/25)*cos(2*pi*xin_new/25);
error_in = slope_curve_in-slope_in;
xin_new = xin_new+0.01;
end
x_save = [x_save;xin_new];
y_save = [y_save;yin_new];
end
xfar_in = x_save;
yfar_in = y_save;
% xfar_in = xin_new;
% yfar_in = yin_new;
% d_in = sqrt(((x_veh-xfar_in)^2) + ((y_veh-yfar_in)^2));
%
% m1=tan(hdg);
% m2=(y_veh-yfar_in)/(x_veh-xfar_in);
% farangle=atan((m1-m2)/(1+m1*m2));
  1 Commento
Joe Jones
Joe Jones il 12 Lug 2022
Dear
Did you solve this problem ?
I also had this problem recently. "An error occurred while propagating data type 'double' through 'adrc/cg_adrc'". (the last problem in the attached picture 'erroes.JPG')
Hope you can help me if possible. Thank you.

Accedi per commentare.

Risposte (1)

Walter Roberson
Walter Roberson il 30 Giu 2018
You need to preallocate the output variable and assign into the appropriate locations in it, instead of dynamically growing your array.
  10 Commenti
Sanjal C C
Sanjal C C il 30 Giu 2018
Yeah really sorry.I could not see your comments and I have attached previously my updated code.
Walter Roberson
Walter Roberson il 30 Giu 2018
Maybe you want something like,
function [xfar_in,yfar_in] = fartheta(y_veh,x_veh,error_in)
nveh = length(x_veh);
x_save = zeros(1, nveh);
y_save = zeros(1, nveh);
for i = 1:nveh
xin_new = x_veh(i);
yin_new = y_veh(i);
error_in = 0.001;
while true
xin_new = xin_new + 0.01;
yin_new = 1*sin(2*pi*xin_new/25);
slope_in = (yin_new-y_veh(i)) ./ (xin_new-x_veh(i));
slope_curve_in = (1*2*pi/25)*cos(2*pi*xin_new/25);
error_in = slope_curve_in-slope_in;
if error_in <= 0
break;
end
xin_new = xin_new+0.01;
end
x_save(1,i) = xin_new;
y_save(1,i) = yin_new;
end
and here calculate xfar_in and yfar_in

Accedi per commentare.

Categorie

Scopri di più su General Applications in Help Center e File Exchange

Prodotti

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by