Error Message while executing these function - Unbalanced or unexpected parenthesis or bracket

1 visualizzazione (ultimi 30 giorni)
Hi, While running the main.m, I am getting unbalanced or unexpected parenthesis or bracket error. Appreciate your help.
%Main Function(Main.m)
clear all;
%Defining the intial conditions
target=[2.8 11.0]; %Final point
pos=[3 0]; %Initial point
vel=[0 0]; %Initial velocity
T=100;
dt=0.1;
RFC=[2.4 0.06 0.6 0.09 10 0.08];
AFC=0.008;
WFC=[10 20];
n=1;
%Obstacle d
d_w=0.6;d_h=1.2;
d1_x=[0.6];d1_y=[7.2];
% d2_x=[3.9];d2_y=[6.9];
% d3_x=[2.4];d3_y=[8.7];
obstacle_all=[d1_x,d1_y];
cl1=length( obstacle_all(:,1));
cl2=length( obstacle_all(:,2));
[A0]=distributingthepoints(n,d_w,d_h,cl1,cl2,obstacle_all);
-----------------------------------
%called function: distributingthepoints.m
function [AA1,AA2] = distributingthepoints(n,d_w,d_h,obstacle_all(1),obstacle_all(2))
A1=[];A2=[];
for I=1:n
for i=1:length(obstacle_all)
X(i,1)=[obstacle_all(1):0.1:obstacle_all(1)+d_w];
X(i,2)=[obstacle_all(2):0.1:obstacle_all(2)+d_h];
for j1=1:length(X(i,1))
a1=[obstacle_all(1),X((i,1)j1)];
A1=[A1;a1];
end
for j2=1:length(X(i,2))
a2=[obstacle_all(2),X((i,2)j2)];
A2=[A2;a2];
end
end
end
end

Risposte (1)

James Tursa
James Tursa il 4 Ago 2015
Modificato: James Tursa il 4 Ago 2015
Don't use subscripts in function argument lists. I.e., don't use the (1) and (2) below:
function [AA1,AA2] = distributingthepoints(n,d_w,d_h,obstacle_all(1),obstacle_all(2))
This should look something like this instead:
function [AA1,AA2] = distributingthepoints(n,d_w,d_h,obstacle_all)
Then you can use subscripted values obstacle_all(1) and obstacle_all(2) inside the function.
Having said that, however, it looks like there will be an argument mismatch in this call:
[A0]=distributingthepoints(n,d_w,d_h,cl1,cl2,obstacle_all);
The number of arguments will not match up with the function. Maybe you can just eliminate the cl1 and cl2 since it doesn't appear they are used inside your function.
  2 Commenti
anantha jaganaghthan
anantha jaganaghthan il 4 Ago 2015
I am still getting same error msg after fixing argument mismatch. I am suspecting error in these code but not sure. appreciate your feedback.
X(i,1)=[obstacle_all(1):0.1:obstacle_all(1)+d_w];
X(i,2)=[obstacle_all(2):0.1:obstacle_all(2)+d_h];
%distributept.m
function [AA1,AA2] = distributept(n,d_w,d_h,obstacle_all)
A1=[];A2=[];
for I=1:n
for i=1:length(obstacle_all)
X(i,1)=[obstacle_all(1):0.1:obstacle_all(1)+d_w];
X(i,2)=[obstacle_all(2):0.1:obstacle_all(2)+d_h];
for j1=1:length(X(i,1))
a1=[obstacle_all(1),X((i,1)j1)];
A1=[A1;a1];
end
for j2=1:length(X(i,2))
a2=[obstacle_all(2),X((i,2)j2)];
end
A2=[A2;a2];
end
end end

Accedi per commentare.

Categorie

Scopri di più su Creating and Concatenating Matrices in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by