You can debug your programs in the following ways:

- Divide the program into several shorter sections and try each section separately.
- Write the results of the calculations in the middle stages of the program flow. You can do this easily by removing the semicolon (;) from the end of the calculation statement or writing the name of the variable. You can also find out how far the program has progressed by placing
*disp*in certain places in the program. - As much as possible, try to use matrix operations and reduce the number of loops that do the same thing in the program.

Execute the suspicious lines of the program separately in the MATLAB workspace (preferably “with the help of copy-paste) to find out the correctness or incorrectness of the calculation. - Pay attention to what line of the program the error message is given and especially pay attention to what the error message is and what it means.
- Take advantage of debugging features available in the software.

## Error messages

Most of the error messages you receive when you first start working with MATLAB are related to vector / matrix operations and substitutions. This section shows how to correct the program using the received error messages with an example.

Consider that you want to draw the PVT level based on the full gas law. The input data to the program are pressure and temperature ranges, and the program must calculate the specific volume of gas and then plot the surface. It is best to do the volume calculation in a separate function so that if you want to repeat the calculation with another state equation, you do not need to re-write the original program and just change the volume calculation function. Suppose you have created the main program and the required function in the first place as follows:

## Main code (main.m):

% Input p = input(‘ Pressure (bar) = ‘); t = input(‘ Temperature (K) = ‘); % Calculation v = ideal(t,p*1e5); % Plotting results surf(p,vol,t)

### sub-function (ideal.m):

function v = ideal(t,p) R = 8314; % Gas constant (J/kmol.K) v = R*t/p; % Ideal gas law

Now if you run this program, you will receive the following error message:

» main Pressure (bar) = [1:10] Temperature (K) = 300:5:400 ??? Error using ==> / Matrix dimensions must agree. Error in ==> C:\MATLABR11\work\ideal.m On line 4 ==> v = R*t/p; % Ideal gas law Error in ==> C:\MATLABR11\work\main.m On line 6 ==> v = ideal(t,p*1e5);

As you can see, the error is taken from line 6 of the main program, which is related to the reference to the function, and in fact there is an error in line ٤ of the function and specifically “in the division of the two vectors t and p. Remember that in matrix operations, the dimensions of the matrices must allow such an operation to be performed. Here it is not possible to perform the division operation with two vectors t and p, and in principle, in this case, the expression used to calculate the full gas volume is not to perform a matrix calculation. Therefore, the line ideal of the ideal.m function is changed as follows (using the division of a member into a member instead of a matrix) so that the volume is not calculated as a matrix:

function v = ideal(t,p) R = 8314; % Gas constant (J/kmol.K) v = R*t./p; % Ideal gas law

But by re-running the program, you will see that the problem is not solved:

» main Pressure (bar) = [1:10] Temperature (K) = 300:5:400 ??? Error using ==> ./ Matrix dimensions must agree. Error in ==> C:\MATLABR11\work\ideal.m On line 4 ==> v = R*t./p; % Ideal gas law Error in ==> C:\MATLABR11\work\main.m On line 6 ==> v = ideal(t,p*1e5);

If we want the number of components of t and p vectors in MATLAB work environment:

» length(p) ans = 10 » length(t) ans = 21

It can be seen that these two vectors are not the same size and therefore member-to-member operations cannot be performed on them. Here you have no choice but to use a loop in the calculations and calculate the values of the specific volume in terms of temperature, each time at a certain pressure:

function v = ideal(t,p) R = 8314; % Gas constant (J/kmol.K) for k = 1:length(p) v(:,k) = R*t/p(k); % Ideal gas law end

But this time you will get an error message:

» main Pressure (bar) = [1:10] Temperature (K) = 300:5:400 ??? In an assignment A(:,matrix) = B, the number of elements in the subscript of A and the number of columns in B must be the same. Error in ==> C:\MATLABR11\work\ideal.m On line 5 ==> v(:,k) = R*t/p(k); % Ideal gas law Error in ==> C:\MATLABR11\work\main.m On line 6 ==> v = ideal(t,p*1e5);

Note that the temperature vector is a linear vector, so to the right of the expression will be the volume calculation of a linear vector. This is while on the left side of the same phrase is a columnar vector and the error message is derived from here. Therefore, the ideal function.m should be corrected as follows:

function v = ideal(t,p) R = 8314; % Gas constant (J/kmol.K) for k = 1:length(p) v(k,:) = R*t/p(k); % Ideal gas law end

This time, by running the main program, you will see the following message:

» main Pressure (bar) = [1:10] Temperature (K) = 300:5:400 ??? Undefined function or variable ‘vol’. Error in ==> C:\MATLABR11\work\main.m On line 9 ==> surf(p,vol,t)

Error message again! But if you pay attention, you will see that this time the error message is not related to the ideal.m function, but the error is taken from the command related to drawing data. In fact, the function has done its job well and has been fixed. The error this time is due to an error in the variable name. The variable v, previously “incorrectly defined”, is used in the surf statement as vol. But vol has not been defined before and as a result, MATLAB does not recognize it. After correcting this line, the main program will be as follows:

% Input p = input(‘ Pressure (bar) = ‘); t = input(‘ Temperature (K) = ‘); % Calculation v = ideal(t,p*1e5); % Plotting results surf(p,v,t)

Running this program will follow the following message:

» main Pressure (bar) = [1:10] Temperature (K) = 300:5:400 ??? Error using ==> surface Matrix dimensions must agree. Error in ==> C:\MATLABR11\toolbox\matlab\graph3d\surf.m On line 59 ==> hh = surface(varargin{:}); Error in ==> C:\MATLABR11\work\main.m On line 9 ==> surf(p,v,t)

This time the error is again related to the surf command and this time it is about how to introduce arrays to it. By referring to the explanations (help) of this command, it is specified that the first and second arguments of this command can be vectors, but the third argument must be a matrix. In this case, the lengths of the first and second arguments must be equal to the number of columns and rows of the third argument, respectively. Therefore, according to these explanations, the variable v should be the third argument of the surf command, and also by observing the dimensions of this variable:

» size(v) ans = 10 21

You can say that the first argument must be a vector t and the second argument must be a vector p. Therefore, the main program should be modified as follows:

% Input p = input(‘ Pressure (bar) = ‘); t = input(‘ Temperature (K) = ‘); % Calculation v = ideal(t,p*1e5); % Plotting results surf(t,p,v) xlabel(‘T (K)’) ylabel(‘P (bar)’) zlabel(‘V (m^3/kmol)’) view(135,30)

If you run the program, you will see the final result.

» main Pressure (bar) = [1:10] Temperature (K) = 300:5:400

Hello,

My program has an error titled:

Error using evalfismex Illegal parameters in fisGaussianMF() –> sigma = 0 Error in evalfis (line 84) [output,IRR,ORR,ARR] = evalfismex(input, fis, numofpoints); Error in ANFIS (line 32) TestOut=evalfis(rr,fis2);

Can you help us?

I will be grateful

Solution :

Hi

This error is one of the most common errors when teaching ANFIS in MATLAB.

This is because the value of sigma in the membership function cannot be zero.

Because ANFIS fis is a Takagi Soguno fuzzy system training algorithm, this may happen.

So what should we do to fix this error:

1. Change the type of function with which you created the fuzzy system, for example, change genfis1 to genfis2.

This error is more common in genfis1

2 – Reduce the number of training samples.

3- Normalize the data before applying it to ANFIS . The normalization commands are mapminamx and mapstd.

4 – Change the type of membership function in the fuzzy system, for example, turn Gaiosin into a triangle.

5. Reduce the number of membership functions in the fuzzy system.

Hi, my program gives this error in executing the following command code, please help

ruleview(fis); Error using & Not enough input arguments. Error in evalfis (line 84) [output,IRR,ORR,ARR] = evalfismex(input, fis, numofpoints); Error in ruleview (line 451) [v,irr,orr,arr]=evalfis(inputVector,fis, numPts); Error in ruleview (line 313) ruleview #update

clc; clear; close all; %%creat fis fisName=’pr’; fisType=’mamdani’; andMethod=’min’; orMethod=’max’; impMethod=’and’; aggMethod=’max’; defuzzMethod=’bisector’; fis=newfis(fisName,fisType,andMethod,orMethod,impMethod, aggMethod,defuzzMethod) ; %%add var % fis=addvar(fis,’varType’,’varName’,varBounds) fis=addvar(fis,’input’,’distance’,[0 1.5]); fis=addmf(fis,’input’,1,’ld’,’trapmf’,[-inf -inf 0.25 0.5]); fis=addmf(fis,’input’,1,’ad’,’trapmf’,[0.25 0.5 0.75 1 ]); fis=addmf(fis,’input’,1,’gd’,’trapmf’,[0.75 1 inf inf]); fis=addvar(fis,’input’,’psc’,[0 1]); fis=addmf(fis,’input’,2,’wl’,’trapmf’,[-inf -inf 0.001 0.25]); fis=addmf(fis,’input’,2,’al’,’trapmf’,[0.001 0.25 0.5 0.75]); fis=addmf(fis,’input’,2,’sl’,’trapmf’,[0.5 0.75 inf inf]); fis=addvar(fis,’output’,’best ‘,[0 1]); fis=addmf(fis,’output’,1,’vb’,’trapmf’,[-inf -inf 0.1 0.25]); fis=addmf(fis,’output’,1,’bb’,’trimf’,[0.1 0.25 0.35]); fis=addmf(fis,’output’,1,’ab’,’trimf’,[0.25 0.35 0.55]); fis=addmf(fis,’output’,1,’gb’,’trimf’,[0.35 0.55 0.75]); fis=addmf(fis,’output’,1,’vg’,’trapmf’,[0.55 0.75 inf inf]); %add rules rules=[1 1 2 1 1 1 2 4 1 1 1 3 5 1 1 2 1 1 1 1 2 2 3 1 1 2 3 4 1 1 3 1 1 1 1 3 2 2 1 1 3 3 2 1 1]; fis=addrule(fis,rules);

I ran your program with MATLAB 2015

No problem

Hello, thank you for your answer

I also run with MATLAB 2012, there is no error,

But when I click the ruleview (fis) it gives the above error

I do not know why? I took all my time?

Do you use this command to show the Rolls or do you have the same error?

please guide me

Hi

one question

Can the output of a fuzzy system be stored in a matrix?

**solution :**

Hello, yes, it is possible

After building a fuzzy system if its name is fis

Just write

y = evalfis (fis, x)

With this command, you give input x to the fuzzy system and save the output in the y matrix.

Hi

Can the inputs of the evalfis command consist of two matrices? That is, instead of giving a specific number, can the numbers already stored in a representation or matrix be used?

Thanks

Hi

Yes you can swipe one matrix once and then the next matrix

For example, suppose we have two matrices named a1 and a2

y1 = evalfis (fis, a1)

y2 = evalfis (fis, a2)

Just be aware that the input numbers are in the range of changes to the fuzzy system inputs.

be happy

Hi

Yes, I am going to form a mesh network with 40 nodes or nodes, which is in a space with a diameter of 500m, where the first and last nodes are at both ends of the diameter and the other nodes are spread in the same range. I put the nodes on the screen, but I could not define the diameter for him.

Thanks

Hi

I saw the part of the code you sent. But I did not see any problem in the code.

The only help I can make is for you to make a condition for the coordinates of each node or node that if this condition holds, one node will be accepted and another node will be generated. In this case, the generated nodes are produced in one range.

That was the help I could get

be happy

This is the part of the code that I used to generate the nodes that actually creates the nodes, but I could not define the diameter

clear all; clc; close all; tic; global n distanc distance ncand ci psc i j k %axis on; axis off; %hazf mehvar mokhtasat x1=0.15; y1=0.15; figure(1); hold on ; box on; grid off; % box off; plot (x1 , y1 , ‘r:o’, ‘MarkerSize’,20); text(x1,y1,’S’); hold on; % matris distance %*b=zeros(1,100); %*d=repmat(b,1,100); %tedad node n=input(‘n=’); ncand=input(‘ncand=’);%max tedad candid a.x=zeros(1,n); a.y=zeros(1,n); %m matris mokhtasat m=repmat(a,1,n); m(1).x=0.15; m(1).y=0.15; rng( 5);%ran num sabet for i=2:n-1 hold on; %* disp(‘*****************************************************************************’); %* fprintf(‘node i= %d \n’,i); xx=rand(1);yy=rand(1); m(i).x=xx; m(i).y=yy; %* disp(‘coordinate=’ ); disp (m(i)); plot (xx,yy,’k:o’, ‘MarkerSize’, 20 ); %lable node labels = cellstr( num2str((i)) ); text(xx,yy, labels); hold on; end xn=0.95; m(n).x=0.95; m(n).y=0.95; yn=0.95; plot (xn, yn , ‘r:o’, ‘MarkerSize’,20); text(xn,yn,’d’); hold on; o=zeros(1,1); p=zeros(1,1); q=zeros(1,1); c=zeros(1,1); distance=repmat(p,100,n);%matris distance for node to node distanc=repmat(o,1,n);%matris distanc to destinection %*dist=repmat(q,1,n); count=repmat(c,1,n);%%%%%%counter tedad neighber every node for i=1:n-1 x2=m(i).x; y2=m(i).y; dn=((x2 – xn) .^ 2 + (y2 -yn) .^ 2); %* disp(‘***************************’); %* fprintf(‘node i= %d \n’,i); hn=abs(sqrt(dn)); %* fprintf(‘dist to dest= %f \n’,hn); digits(3); distanc(i)=hn; end % distance is matris fasele node to node %* disp(‘***************************’); l=zeros(1,1); sp=repmat(l,1,n);%successprob x2=zeros(1,1); psc=repmat(x2,100,n);%sort sp base ci for i=1:n for j=1:n % j=j+1; x2 = m(j).x; y2 = m(j).y; d=((m(i).x – x2) .^ 2 + (m(i).y -y2) .^ 2); % *disp(‘***************************’); %* fprintf(‘node i,j= %d \n’,i); h=abs(sqrt(d)); %ta 3 ragham ashar digits(3); %* fprintf(‘dist to dest= %f \n’,h); distance(i,j)=h;

Hi, thanks

So there is no place in MATLAB to define the diameter of the page?

It can be done.

MATLAB has a tool for meshing called PDEtool

We have a student in this regard. In this tool, you can easily do meshing.

Hi

Where is the problem with the following program that can not be run? Thanks for the help of dear friends

clc,clear,close all f1t=1080; f1c=620; f2t=39; f2c=128; f6=89; syms sx s1 s2 t6 step=pi/6; for theta=0:step:pi/2; m=cos(theta); n=sin(theta); my_sys=[s1-m^2*sx,s2-n^2*sx,t6-m*n*sx,(1/f1t-1/f1c)*s1+(1/f2t-1/f2c)*s2+(1/(f1t*f1c))*s1^2+(1/(f2t*f2c))*s2^2+t6^2/f6^2-(1/(f1t*f1c*f2t*f2c)^0.5)*s1*s2-1]; Resp=solve(my_sys); Maxsx(:,1+theta/step)=double(Resp.sx); end theta=(0:step:2*pi).*(180/pi); % Theta in Degree plot(theta,MaxSx),xlabel(‘Theta’),ylabel(‘Max Stress’)

Hi

You put the chart at the end of the program

plot (theta, Maxsx),

But the length of the two input vectors of the plot command is not equal.

The Maxsx matrix is also obtained.

Execute the code step by step.

Hello, it gives this error for displaying trans in the program article

please error at ohm:usage might be invalid matlab syntax please error at’0.0090′:usage might be invalid matlab syntax

This is the complete program if you can help me

To obtain equivalent circuit from tests 1 To input individual winding impedances 2 To input transformer equivalent impedance 3 To quit 0 Select number of menu –> 2 Enter Transformer rated power in kVA, S = 150 Enter rated low voltage in volts = 240 Enter rated high voltage in volts = 2400 Enter LV winding series impedance R1+j*X1 in ohm=0.002+j*.0045 Enter HV winding series impedance R2+j*X2 in ohm=0.2+j*0.45 Enter ‘lv’ within quotes for low side shunt branch or enter ‘hv’ within quotes for high side shunt branch -> ‘hv’ Shunt resistance in ohm (if neglected enter inf) = 1000 Shunt reactance in ohm (if neglected enter inf) = 1500 Shunt branch ref. to LV side Shunt branch ref. to HV side Rc = 10.000 ohm Rc = 1000.000 ohm Xm = 15.000 ohm Xm = 1500.000 ohm Series branch ref. to LV side Series branch ref.to HV side Ze = 0.0040 + j 0.0090 ohm Ze = 0.4000 + j 0.90 ohm Hit return to continue Enter load kVA, S2 = 150 Enter load power factor, pf = 0.8 Enter ‘lg’ within quotes for lagging pf or ‘ld’ within quotes for leading pf -> ‘lg’ Enter load terminal voltage in volt, V2 = 240 Secondary load voltage = 240.000 V Secondary load current = 625.000 A at -36.87 degrees Current ref. to primary = 62.500 A at -36.87 degrees Primary no-load current = 2.949 A at -33.69 degrees Primary input current = 65.445 A at -36.73 degrees Primary input voltage = 2453.933 V at 0.70 degrees Voltage regulation = 2.247 percent Transformer efficiency = 94.249 percent Maximum efficiency is 95.238 %occurs at 288 kVA with 0.8pf

Hi

How can the following return relation be coded in MATLAB? I have a problem in the return part of the equal dimension relation (EAX (ci, d).

(EAX (s, d) = Ʃ EAX (ci, d) pi Π (1-pj

Sigma interval (i = 1… c) and π are equal to j = 1 ..i-1

In case i = 1 the expression Π (1-pj) = 1.

please guide me

Thanks

Hi

I can not tell you the exact code, the only advice I can give is that it always takes two things to write each return relation.

First initialize the variable to be set in the process

Second, use a FOR loop to write the process

Well you come first

Π (1-pj) = 1

put the

Then write a FOR loop

Use the prod command to write the product of several (Π) numbers together.

Hello, whatever code I write is still wrong, please help, it is very necessary

function e=followeax(c,d) global n distanc distance ncand ci psc sp maxCandidateset res zzz c %%%%% eax 1) for i=2:zzz(k) for j=1:i-1 mult1=1; EE=mult1*(1-sp(1,j)); end % rr= maxCandidateset(1,i); % eax=1+(followeax(maxCandidateset(i,1),n))*sp(i,1)*EE ; rr= maxCandidateset(1,i); eax=1+followeax(rr,n)*sp(rr,i)*EE ; end end end %h=maxCandidateset(c,1); % eax= 1+followeax(h,n)*sp(c,1);

This gives the error

Output argument “e” (and maybe others) not assigned during call to “D: \ ms hoosh \ term2 \ tez1 \ followeax.m> followeax ”. Error in followeax (line 9) eax = 1 + followeax (rr, n) * psc (rr, i);

function e = followeax (c, n) global n psc sp maxCandidateset zzz eax rr d %%%%% eax 0) % if (zzz (rr)> 1) % for i = 2: zzz (k) for j = 1: i-1 mult1 = 1; EE = mult1 * (1-psc (1, j)); end % rr = maxCandidateset (1, i); % eax = 1 + (followeax (maxCandidateset (i, 1), n)) * sp (i, 1) * EE; rr = maxCandidateset (rr, i); eax = eax + 1 + followeax (rr, d) * psc (rr, i) * EE; end end end % end % h = maxCandidateset (c, 1); % eax = 1 + followeax (h, n) * sp (c, 1); df It also gives an error with this code

In followeax (line 11) eax = eax + 1 + followeax (rr, d) * psc (rr, i);

I pay attention, I do not know what it is about?

Hi

In the following code, why does not label the x, y axis in the diagram?

figure(2); axis on; % xlabel=(‘Number of node’); %ylabel=(‘excute time(sec)’); t=[0 2.74 3.09 5.38 6.57 7.63 8.50 9.72 10.52 11.37 12.48 14.74 16.24 16.84 17.02 ]; %t1=[0 4.56 5.39 6.28 6.54 9.67 10.25 11.02 12.00 13.03 16.40 18.38 18.69 19 19.5];%t1base t1=[0 8 10.5 12.8 15 16.54 19.67 20.25 21.02 23.03 26.40 28.38 32.69 35 37];%baseaper number=[0 20 25 30 35 40 45 50 55 60 65 70 75 80 85]; plot (number , t , ‘r:o’, number,t1,’b:+’); title(‘ Execution time for the case ncand = 5’); xlabel=(‘Number of node’); ylabel=(‘excute time(sec)’); hleg1=legend(‘Fuzzyor’,’Dpor’); set(hleg1,’Location’,’NorthWest’);

Hi

Command

`xlabel = (‘Number of nodes’);`

Is wrong

There is no equal sign in this command.

Hello, good morning

My code always warns not enough input argument

What could be the problem ?!

Hi

Fix the error completely.

This error occurs most often when you give a function less than the intended number of inputs

Hello, do not be bored, I designed a fuzzy system, but when entering the membership function in the range [0.1 0] in Gaussian mode, it gives this error invalid parameters vector.no change made to mf gaussmf

What should I do? What should I do?

Thankful

Hi

The gaussmf membership function cannot take the value zero as a parameter.

Change the membership function type or change the range from 0 to 0.0001.

Hi, my program gives this error. What should I do?

```
Reference to non-existent field ‘busdata’.
Error in Cost (line 46)
[row, column] = find (mpc.busdata (:, 1) == a);
Error in pso_opfff (line 52)
particle (i) .cost = Cost (particle (i) .position);
```

Hi

In structure arrays, all fields must be defined.

You called a field called busdata, but in the previous lines you did not specify or define them, and MATLAB got an error from the program that this busdata field is not clear.

Hi, I had a MATLAB coding that when I set the angles to zero, the program runs smoothly, but when I try to change the angle, I get this error. Please help me if possible. This is part of the program.

```
E11 = 39e9; E22 = 8.66e9; G12 = 3.8e9; G13 = G12; G23 = 3.8e9; v12 = 0.28; v21 = v12 * E22 / E11;
aunt = 0;
Q11 = E11 / (1- (v21 * v12)); Q22 = E22 / (1- (v21 * v12)); Q12 = (v12) * E22 / (1- (v21 * v12)); Q66 = G12; Q44 = G23; Q55 = G13;
q_ (1,1) = Q11 * (cosd (teta)) ^ 4 + Q22 * (sind (teta)) ^ 4 + 2 * (Q12 + 2 * Q66) * ((sind (teta)) ^ 2) * (cosd (theta)) ^ 2;
q_ (2,1) = (Q11 + Q22-4 * Q66) * sind (teta) ^ 2 * cosd (teta) ^ 2 + Q12 (sind (teta) ^ 4 + cosd (teta) ^ 4);
```

This shows the error when I set the angle to a value other than zero

Subscript indices must either be real positive integers or logicals.

Hi

In MATLAB, the array indices must be a number greater than 0 and an integer. If you put a number other than this, MATLAB gives an error.

For example

a = [3 5 6 8]

If you have in the program

a (0)

Or

a (1.5)

MATLAB gives this error.

You have to run the program line by line. One of these methods is breakpoint. You can refer to Iran MATLAB movie Garlic to Onion for more explanation.

Hi

I wrote a program in Simulink, of course, which also used a fuzzy controller, but it gives an error when running.

“Invalid FIS file name”

What can I do to fix this error?

Hi

This is a completely obvious error

Or the fuzzy system is not in the MATLAB path that MATLAB cannot find.

The first problem is more likely.

Hi.

I wanted to know what the ORR parameter represents in the evalfis command?

Can you please send the answer to my email?

Thankful.

Hi

ORR output The output value of each membership function of your fuzzy system membership function. Each number of membership functions in your system has the same amount in ORR.

Its size is numPts-by-numRules * L

numPts is the number of instances in the input of the evalfis command.

numRules Number of rules

L is the number of outputs.

For more explanation, you can prepare a comprehensive fuzzy system training package.

Hi

I have a multi-objective optimization program that I want to run with a multi-objective genetic algorithm, but unfortunately, I can not run this error

Optimization running.

Error running optimization.

Not enough input arguments.

Please help, thank you

Hi

This error occurs when you are calling a function but did not enter the correct entries.

For example, the function should take 4 inputs. You came with 2 inputs.

Not enough input argument.

Go to the line that says you gave this function less input and fix the call method.

Hello, the MATLAB app section, the optimization program does not run at all and gives a Java error. Where is the problem?

Hi

The problem is in the MATLAB version.

Install the higher version. Problem solved.

Hello, do I have the following error at the beginning of the program? Can you please help?

Error: File: bisct.m Line: 4 Column: 1

Function definitions are not permitted in this context.

```
Here is my plan:
clear
clc
c (i) = zeros (1, maxlter);
function [cc (i), c (i)] = bisct (f, a, b, t, maxlter)
fa = feval (f, a); fb = feval (f, b); e = eps;
if fa * fb> 0,
disp (‘error’)
end;
n = 0;
for i = 1: maxlter
c (i) = (a + b) / 2; fc = feval (f, c (i));
if abs (fc) <t;
break;
elseif fa * fc <0
b = c (i); fb = fc;
else
a = c (i);
end
n = n + 1;
end
cc (i) = c (i);
```

This parenthesis and poison Kaluna appears correctly in my file

Hi

Dear friend, you can not define a function in a script.

Or you can save the function in an m file and call it in the script.

Or turn your script into a function. In this case, you can define multiple functions in one function.

I recommend method one because it has two advantages. First, if this function is needed in another program, you can easily call it. Secondly, the number of m files you wrote increases and you tell yourself that you are a programmer 🙂

Hi, I wanted to see what the following error means in MATLAB:

Attempt to reference field of non-structure array

Hello and thank you for your question

In MATLAB, we have structural variables. The method of calling them is as follows

A.score

A is a structural variable

score is its field.

Now if you call a non-structural variable as a structural variable, this error will appear.

The field of this variable may not have been set in the previous lines, because then it is a normal variable.

Thank you for your response

The error is taken from the following line:

dim = eldat.compute

Previously defined as global eldat

Given this, your explanation is right now what should I do to fix the error?

Dear user of your service, it was said that the compute field in the eldat variable should be defined before it, not the general variable.

Of course, in MATLAB advanced programming of sub-functions, a function is also called that is not related to your code.

Hi

I wanted to know how to solve a parametric equation in the solve statement?

Also, if I use predefined variables in this command and take a value based on a series of specific parameters, does this command see the values assigned to these variables or does it itself see them as a variable?

Hi

Can not be explained in one post.

You can define a parametric equation with the solve command.

You must first define the variables with the syms command and then define the equation.

This command sees variables defined by the syms command as variables. If you assign a value to them, the variable type changes to the usual double type, and MATLAB no longer considers it a symbolic variable.

```
T = input (‘T =’)
L = input (‘L =’)
B = input (‘B =’)
n = 1100
for i = 1: n
if B / L <0.11
cseven = 0.229577 * (B / L) ^ 0.3333;
else
if 0.11 <B / L0.25
cseven = 0.5-0.0625 * (L / B);
end
end
end
end
```

Hi, what is the problem with this ring? Thank you for answering

Hi

B / L0.25

Must be between B / L and 0.25 times.

Try to define B / L as a new variable so that you do not run into these problems in the program.

Also, make a few conditions after getting the inputs so that the user does not give you an unauthorized number. For example, if L = 0, the denominator of the fraction cannot be zero.

Hi. I defined several functions in MATLAB to do a project. And then I used them in a separate m-file. But when I run the functions separately, it gives the error that the input argument is not enough, and as a result, the Klim program does not run.

I defined these three functions separately in separate mfiles. The first does not give an error when running, but gives an error for the second and third as I said

```
function gen_data = call_gendata
gen_data = [
1 0 350 0.01 0.3 0.2
2 0 1145.55 0.01 0.3 0.2
3 0 750 0.01 0.3 0.2
4 0 732 0.01 0.3 0.2
5 0 608 0.01 0.3 0.2
6 0 750 0.01 0.3 0.2
7 0 660 0.01 0.3 0.2
8 0 640 0.01 0.3 0.2
9 0 930 0.006 0.3 0.2
10 0 1100 0.006 0.3 0.2];
function cost = costfun (x)
gen_data = call_gendata;
x = x ’;
cost = sum (gen_data (:, 4). * x. ^ 2 + gen_data (:, 5). * x + gen_data (:, 6));
objective function = costfunsa (x)
gen_data = call_gendata;
x = x ’;
cost = sum (gen_data (:, 4). * x. ^ 2 + gen_data (:, 5). * x + gen_data (:, 6));
objective = cost + 1e4 * (sum (x) -6254.23). ^ 2;
```

```
This is the main code that I must use for all three functions
demand = 6254.23;
pcf = 1e4;
gen_data = call_gendata;
dimnsn = 10;
mni = 1000;
npop = 100;
lb = gen_data (:, 2) ’;
ub = gen_data (:, 3) ’;
Aeq = ones (1,10);
beq = demand;
x0 = (gen_data (:, 3) + (gen_data (:, 2) - gen_data (:, 3)). * rand (dimnsn, 1)) ’;
options = saoptimset (‘MaxFunEvals’, mni, ‘PlotFcns’, @saplotbestf, ‘StallIterLimit’, inf, ‘TimeLimit’, inf, ‘Display’, ‘iter’)
[x, fval] = simulannealbnd (@ costfunsa, x0, lb, ub, options)
cost = fval-pcf * (sum (x) -demand) ^ 2;
fprintf (‘\ n’), display (‘finalsolution is;’), Fs = x ’
fprintf (‘\ n’), display (‘load not served:‘), loadMismatch = sum (x) -demand
fprintf (‘] n’), display (‘Associated cost:’, cost
```

Hi

The error of not having an argument is a function of an error that can be easily solved.

In this program, you defined a cost for optimization. Be sure to define the cost function according to the MATLAB toolbox.

You may have defined one input but need two inputs.

My suggestion to you is to prepare an optimization training video in MATLAB, the definition of the cost function of which is explained with a few examples.

Hello, why does the following code print the error message instead of executing the second part?

% This make.m is for MATLAB and OCTAVE under Windows, Mac, and Unix

try

Type = ver;

% This part is for OCTAVE

if (strcmp (Type (1) .Name, ‘Octave’) == 1)

mex libsvmread.c

mex libsvmwrite.c

mex svmtrain.c ../svm.cpp svm_model_matlab.c

mex svmpredict.c ../svm.cpp svm_model_matlab.c

% This part is for MATLAB

% Add -largeArrayDims on 64-bit machines of MATLAB

else

mex CFLAGS = ”\ $ CFLAGS -std = c99 lar -largeArrayDims libsvmread.c

mex CFLAGS = ”\ $ CFLAGS -std = c99 lar -largeArrayDims libsvmwrite.c

mex CFLAGS = ”\ $ CFLAGS -std = c99 lar -largeArrayDims svmtrain.c ../svm.cpp svm_model_matlab.c

mex CFLAGS = ”\ $ CFLAGS -std = c99 lar -largeArrayDims svmpredict.c ../svm.cpp svm_model_matlab.c

end

catch

fprintf (‘If make.m fails, please check README about detailed instructions. \ n’);

end

I also installed the c compiler, but it still gets the if make.m fails خط error

Hi

You will see which compiler C you installed. The next point is that you have to compile the c file with your system and then the mex commands will be executed.

The mex file you downloaded from somewhere may cause an error on your system. Therefore, first compile c files with the MATLAB mex command and then run them.

Hello, I have the pitch correction algorithm in Netbla and the program, but I run it. I always find the following error. Please help me.

```
%% Primitive pitch correction function. Requires input STFT, its frequency
%% space, and a table of pitches to compare to. Y can bt the HPS of S or any
%% other peak-accentuated sequence.
function S_corrected = pitchCorrector (S, F, Y, pitchtable)
bins = length (S (1, :));
S_len = length (S (:, 1));
%% Pre-allocates memory for arrays
maxpeaks = zeros (1, bins);
indices = zeros (1, bins);
pitches = zeros (1, bins);
correctedpitches = zeros (1, bins);
ratio = zeros (1, bins);
S_corrected = zeros (S_len, bins);
%% Finds the maximum amplitudes and their corresponding frequencies in the
%% Fourier spectrum. correctedpitches stores the closest exact pitch to
%% each of these maximum pitches. ratio stores the factor by which each
%% ST-spectrum will have to be shifted in order to obtain the correct
%% pitch.
for k = 1: bins
maxpeaks (k) = max (Y (:, k));
indices (k) = find (Y (:, k) == maxpeaks (k), k, ‘first’);
pitches (k) = F (indices (k));
correctedpitches (k) = compareToPitches (pitches (k), pitchtable);
ratio (k) = correctedpitches (k) / pitches (k);
end
%% This for-loop is separate from the previous for debugging purposes.
%% Utilizes the fact that the frequencies in F are spaced linearly, starting at 0, so that
%% the ratio between frequencies is equivalent to the ratios between sample
%% indices. If ratio> 1, S_corrected will end with a number of zeros. If
%% ratio <1, S_corrected will contain many repeated values. Either way,
%% high-frequency information will be lost.
for k = 1: bins
for j = 1: S_len
y = round (j / ratio (k));
%% Prevents negative indices
if y <1
y = 1;
end
%% Non-constant frequency scaling
if y <= S_len
S_corrected (j, k) = S ((y), k);
end
end
end
end
Error observed:
pitchCorrector
Error using pitchCorrector (line 6)
Not enough input arguments.
```

Hi

As you can see, your function has 4 inputs, but you do not input it properly.

Error

Not enough input arguments

That means you did not set the number of function inputs to 4.

Hi

It gives an error when I want to reverse the 6 * 6 parametric matrix.

Is the problem due to the weakness of the system? I tested 7 cores and 16 RAM on 3 other systems, but it still gives the same error

Is there a problem with the badly written code and the occupation of Roman space?

How do I get an inverse 6-by-6 parametric matrix?

The square of the scroll bar is green and should not be a problem.

I attached the code.

Thank you for checking and replying.

```
clc;
clear;
% dynamic inverse
syms r_u r_d alfa_u alfa_d z_cg h_0 si fi teta x y z i_xx i_xy i_zx i_zy i_yx i_xz i_yy i_yz i_zz m_p v_x v_y v_z vdot_x vdot_y vdot_z omega xg omeg_ome
g = 9.81;
i_xy = i_yx;
i_xz = i_zx;
i_yz = i_zy;
e_11 = cos (teta) * cos (si);
e_21 = cos (teta) * sin (si);
e_31 = -sin (teta);
e_12 = sin (fi) * sin (teta) * cos (si) -cos (fi) * sin (si);
e_22 = sin (fi) * sin (teta) * sin (si) + cos (fi) * cos (si);
e_32 = sin (fi) * cos (teta);
e_13 = cos (fi) * sin (teta) * cos (si) + sin (fi) * sin (si);
e_23 = cos (fi) * sin (teta) * sin (si) -sin (fi) * cos (si);
e_33 = cos (fi) * cos (teta);
x_u = sym (zeros (1,6));
y_u = sym (zeros (1,6));
z_u = sym (zeros (1,6));
x_d0 = sym (zeros (1,6));
y_d0 = sym (zeros (1,6));
z_d0 = sym (zeros (1,6));
x_d = sym (zeros (1,6));
y_d = sym (zeros (1,6));
z_d = sym (zeros (1,6));
l = sym (zeros (1,6));
u_x = sym (zeros (1,6));
u_y = sym (zeros (1,6));
u_z = sym (zeros (1,6));
for i = 1: 6
x_u (i) = r_u * cos ((pi / 3) * (i) + (- 1) ^ i * alfa_u / 2);
y_u (i) = r_u * sin ((pi / 3) * (i) + (- 1) ^ i * alfa_u / 2);
z_u (i) = z_cg;
x_d0 (i) = r_d * cos (((2 * (1+ (2/3) * (i-1)) - 2) * pi / 3) - (- 1) ^ i * alfa_d / 2);
y_d0 (i) = r_d * sin (((2 * (1+ (2/3) * (i-1)) - 2) * pi / 3) - (- 1) ^ i * alfa_d / 2);
z_d0 (i) = z_cg + h_0;
x_d (i) = e_11 * x_d0 (i) + e_12 * y_d0 (i) + e_13 * z_d0 (i) + x;
y_d (i) = e_21 * x_d0 (i) + e_22 * y_d0 (i) + e_23 * z_d0 (i) + y;
z_d (i) = e_31 * x_d0 (i) + e_32 * y_d0 (i) + e_33 * z_d0 (i) + z;
l (i) = sqrt ((x_u (i) -x_d (i)) ^ 2+ (y_u (i) -y_d (i)) ^ 2+ (z_u (i) -z_d (i)) ^ 2);
u_x (i) = (x_d (i) -x_u (i)) / l (i);
u_y (i) = (y_d (i) -y_u (i)) / l (i);
u_z (i) = (z_d (i) -z_u (i)) / l (i);
end
A = [u_x (1) u_x (2) u_x (3) u_x (4) u_x (5) u_x (6); u_y (1) u_y (2) u_y (3) u_y (4) u_y (5) u_y ( 6); u_z (1) u_z (2) u_z (3) u_z (4) u_z (5) u_z (6); u_z (1) * y_u (1) -u_y (1) * z_u (1) u_z (2 ) * y_u (2) -u_y (2) * z_u (2) u_z (3) * y_u (3) -u_y (3) * z_u (3) u_z (4) * y_u (4) -u_y (4) * z_u (4) u_z (5) * y_u (5) -u_y (5) * z_u (5) u_z (6) * y_u (6) -u_y (6) * z_u (6); - u_z (1) * x_u (1) + u_x (1) * z_u (1) -u_z (2) * x_u (2) + u_x (2) * z_u (2) -u_z (3) * x_u (3) + u_x (3) * z_u (3) -u_z (4) * x_u (4) + u_x (4) * z_u (4) -u_z (5) * x_u (5) + u_x (5) * z_u (5) -u_z (6) * x_u (6) + u_x (6) * z_u (6); u_y (1) * x_u (1) -u_x (1) * y_u (1) u_y (2) * x_u (2) -u_x (2) * y_u ( 2) u_y (3) * x_u (3) -u_x (3) * y_u (3) u_y (4) * x_u (4) -u_x (4) * y_u (4) u_y (5) * x_u (5) - u_x (5) * y_u (5) u_y (6) * x_u (6) -u_x (6) * y_u (6)];
B = [m_p * (vdot_x-v_y * omega_z + v_z * omega_y + g * sin (teta)); m_p * (vdot_y-v_z * omega_x + v_x * omega_z-g * sin (fi) * cos (teta)); m_p * (vdot_z-v_x * omega_y + v_y * omega_x-g * cos (fi) * cos (teta)); i_xx * omegadot_x + i_xy * (omega_x * omega_z-omegadot_y) -i_xz * (omega_x * omeg omega_y * omega_z * (i_zz-i_yy) + i_yz * (omega_z ^ 2-omega_y ^ 2); i_yy * omegadot_y-i_xy * (omega_y * omega_z + omegadot_x) + i_xz * (omega_x z_ 2 omega_z * (i_xx-i_zz) + i_yz * (omega_x * omega_y-omegadot_z); i_zz * omegadot_z + i_xy * (omega_y ^ 2-omega_x ^ 2) + i_xz * (omega_x * omeg_z_ ( -i_xx) -i_yz * (omega_x * omega_z + omegadot_y)];
F = (inv (A)) * B;
```

Hi

You used symbolic variables. Excessive use of these variables prevents MATLAB from running the program.

I do not understand the reason for using these variables.

Next point, the inv function does not accept the symbolic variable.

greetings and respect

I simulated a model in Simulink that includes 3 mode spaces and 3 controllers. When I run, one of the mode spaces turns yellow and gives a message.

*Derivative input 1 of ‘simulink123 / State-Space’ at time 0.13263028511581632 is Inf or NaN. Stopping simulation. There may be a singularity in the solution. If not, try reducing the step size (either by reducing the fixed step size or by tightening the error tolerances)*

I do not know where the problem comes from. I set the initial conditions for the mode space, but it did not return. Thank you for your help.

To summarize, Simulink uses numerical solution methods to weave the answer. In your model, this equation becomes problematic at the desired time.

Hi

Do not be tired

MATLAB code is executed on my master computer, but the same code was executed once in my system, but everything I did can no longer be executed, even though I did not change the code at all.

```
Gets the following errors:
??? Index exceeds matrix dimensions.
Error in ==> Rout at 27
[value, next] = max (x (negbr));
Error in ==> fitness at 3
path = Rout (HS_Vector, indexI, Sensor, allneighber_, dist, dmax);
Error in ==> BatAlgorithm at 51
pop (i) .fit = fitness (fitnes, pop (i) .x, indexI, Sensor, allneighber_, dist, dmax, packet_size, Eelec, EFamp, ETamp);
Error in ==> HS at 25
pop = BatAlgorithm (fitnes, N, Sensor, indexI, dist, dmax, packet_size, Eelec, EFamp, ETamp, allneighber_);
Error in ==> WSN at 78
path = HS (fitness, Number_of_Node, Sensor, i, dist, dmax, packet_size, Eelec, EFamp, ETamp, allneighber);% [i, Number_of_Node + 1];%
Error in ==> test at 15
WSN (Sensor (1: Number_of_Nodes), Number_of_Nodes, Eo, equ, xm, ym, ‘black’);
```

Hello and do not be tired of your service

I run into this error while running the program. Can you please help me?

```
Error in evalfis (line 83)
[output, IRR, ORR, ARR] = evalfismex (input, file, numofpoints);
Error in Degree (line 37)
FF1 = evalfis ([- 1,1], F1);
Thank you very much
```

Hello and thank you

Most likely you were wrong in defining the Takagi Sugeno system.

If this is not the case then maybe your query is incorrect. For example, your system may have one input and you have two inputs.

Hello and do not be tired.

I run the following MATLAB program or error, and it does not run at all:

[ERROR USING OPEN [100 LINE

FILE E;: /…. / NEW FOLDER / ST1 NOT FOUND

what is the problem?

Hi

Dear friend, as MATLAB has explained in error. Could not find the path specified in E: /… ../ NEW FOLDER / ST1. Most likely this route does not exist.

Hi

Do not be tired

Excuse me, what does this error mean?

Too many input arguments

I wrote the fwhm calculation program in a function and now when I call it in a program, it gives this error…

Thank you for your help

Hi

If you also pay attention to the translation of the error, you are calling the written function with more entries.

Hi

I run the following error while running my program. Apparently, I do not have the nargoutchk.m version because it is low, where can I find this code?

```
Error using ==> nargoutchk
Not enough input arguments.
Error in ==> ace at 79
nargoutchk (0.7)
```

Hi

Error

Not enough input arguments

It means that the number of inputs of the nargoutchk function is small.

This function checks the output number of the function.

Hi. I have a problem

`error: unexpected Matlab expression`

Please help me

Hi

You must enter MATLAB commands in a specific format. Sometimes omitting a comma or parentheses… causes this error.

Check the line that caused this error.

Hi

In MATLAB command

x (a: b) = c;

That is, cells a to b fill array x with a constant value of c.

This command means to fill 1 to ten thousand from home with 100.

Hello, I wrote a program, but I encountered this error. What should I do?

```
Attempted to access xx (2); index out of bounds because numel (xx) = 1.
Error in truss (line 41)
xa = xx (index (2)) - xx (index (1));
```

Hi

Error

index out of bounds

There are times when you call an array cell that does not exist. The second cell of the xx array does not exist.

Hi

I want to save an audio file in MATLAB I used to use wavwrite and it was not a problem but now that I have installed the new version of MATLAB I get the following error when using audiowrite

```
Error using audiowrite> validateFilename (line 323)
Cannot create file ccc.wav. Permission Denied.
Error in audiowrite (line 105)
[props.filename, fileExisted] = validateFilename (props.filename);
```

I’m really upset, please help me

Hi

Another post, you did not set permission.

Right click on the file and set permission.

Hi

I wrote an optimization code with pso that when I executed it I realized that some restrictions are not satisfied and I made a change in the code that only adds fixed values to some of my results and I did not change the optimization variable but now the program does not run and with I will encounter the following error, if you can guide me.

```
Reference to non-existent field ‘Position’.
Error in pso (line 61)
particle (i) .Velocity = w * particle (i) .Velocity…
```

Hi

The particle variable is a structural variable and has fields. You wrote particle (i) in the program. Velocity, but it looks like the particle variable does not have this field.

Hi

I wrote the following command in MATLAB. Runs but does not display legend. And gives an error. Thank you for your help.

```
clc;
clear;
close all;
f0 = 2;
t = 0: 0.01: 2;
x = cos (2 * pi * f0 * t);
figure;
plot (t, x, ‘ro:’, ‘markersize’, 12, ‘markerfacecolor’, [0.8 1 0]);
legend (‘cos’);
Error:
Error in legend (line 13)
legend (‘cos’);
```

Hi

I executed the code inside MATLAB.

You missed one of the quotes

That’s right

legend (‘cos’);

Hi

I have a 2000 record data with 41 input parameters that I want to be taught with genfid 3 in the fuzzy nervous system, but unfortunately it gives this error

```
Error using anfismex
Illegal parameters in fisGaussianMF () -> sigma = 0
Error in anfis (line 249)
anfismex (trn_data, in_fismat, t_opt, d_opt, chk_data, method);
Error in prob_a2 (line 83)
matfile_probe = anfis (trnData1, matfile_probe, TrainOptions, DisplayOptions, [], OptimizationMethod);
```

Changing to genfis2 solves the problem, but I have to use clustering in the project

Please advise how to fix this error

Thankful

Hi

This error can occur for several reasons. Type of membership function, degree of membership function, personal training parameters and….

The main reason is that genfis3 uses a derivative or gradient method. If Sigma is zero, this method gives an error.

The problem will be solved if you change the type of membership function or the degree of the membership function.

Greetings

I want to draw the Sigma function as follows. I drew with different commands, but it gives an error. Please advise.

t and u are slave variables.

Thanks

```
>> t = linspace (0.100);
>> u = symsum (2000 / ((2 * m + 1) * pi)) * (sin (0.05 * (2 * m + 1) * pi)) * (exp (-0.25 * pi ^ 2 * (2 * m + 1) ^ 2 * t));
>> plot (t, u)
Error using plot
Conversion to double from sym is not possible.
```

Hi

You used the sym or syms command before these commands. You can use symbolic variables in formulas. If you want to use the resulting number in a phrase, you must first double them. Then use.

Next tip: You can also use the ezplot function, which draws symbolic formulas. Replace ezplot.

Pray if it helps you.

Hello good time

I had a file that I used to run with MATLAB 2007 and it had no problem. But now that I want to open it with MATLAB 2017, it will not run and it will give the following error. Can you help me, what should I do? Because it is .P and I do not have access to it. Thank you.

`The P-code file F: \ low was generated prior to Matlab version 7.5 (R2007b) and is no longer supported. Use pcode to regenerate the file using Matlab R2007b or later.`

Hi

P codes have special encoding and we can not have any access to its content.

One of the problems with MATLAB is that with each new release, some functions are removed and some new ones are added. This is a flaw, but MATLAB continues to do so in every new version.

Hello, do not be bored. My program code is to find the maximum of a function using the genetic method for line 16.

```
Clc;
clear all;
N = 50;
Pc = 0.9;
Pm = 0.005;
ITER = 100;
m = 2;
BS = [10 10];
L = sum (BS);
Lo = [- 2 -3];
Hi = [2 3];
population = round (rand (N, L));
best_so_far = [];
Average_fitness = [];
for it = 1: ITER
[real_val] = chrom_decode (population, N, L, BS, m, Lo, Hi);
[selection_probablity, fit, ave_fit, max_fit, opt_sol] = fit_eval (real_val, N, m);
if it == 1
best_so_far (it) = max_fit;
final_sol = opt_sol;
elseif max_fit> best_so_far (it-1)
best_so_far (it) = max_fit;
final_sol = opt_sol;
elsebest_so_far (it) = best_so_far (it-1);
end
Average_fitness (it) = ave_fit;
[matin_pool] = g-roulette_wheel (population, N, selection_probablity);
[new_pool] = g_crossover (mating_pool, Pc, N, L);
[population] = g_mutation (new_pop, Pm, N, L);
end
display (‘final Solution optimum fitness’);
result = [final_sol, bes_so_far (end)];
x = 1: ITER;
figure, plot (x, best_so_far, ‘k’, x, Average_fitness, ’- k’);
xlabale (‘Generation’);
ylabel (‘Fitness Function’);
legend (‘Best_so_far’, ‘Average fitness’);
%%% chrom_decode.m %%%
function [real_val] = chrom_decode (population, N, L, BS, m, Lo, Hi)
real_val = [];
STED (1) = 1;
for i = 2: m + 1
STED (i) = STED (i-1) + BS (i-1);
end
for j = 1: m
x = BS (j): - 1: 0;
pow2x = 2. ^ x;
for i = 1: N
gene = population (i, STED (j): STED (j + 1) -1);
var_norm = sum (pow2x. * gene) / (2 ^ BS (j) -1);
real_val (i, j) = Lo (j) + (Hi (j) -Lo (j)) * var_norm;
end
end
end
%%% fit_eval.m %%%
function [selection_probablity, fit, ave_fit, max_fit, opt_sol] = fit_eval (real_val, N, m)
for i = 1: N
x = real_val (i, :);
fit (i) = (x (1) ^ 2-x (2) ^ 2 + 4 * x (2) -x (1) * x (2) -4);
end
selection_probablity = fit / sum (fit);
ave_fit = mean (fit);
[max_fit, max_loc] = max_fit;
opt_sol = real_val (max_loc, :);
end
function [mating_pool] = g_rulette_wheel (population, N, selection_probablity)
cdf (1) = selection_probablity (1);
for i = 2: N
cdf (i) = cdf (i-1) + selection_probablity (i);
end
for i = 1: N
q = rand;
for j = 1: N
if q <= cdf (j)
matin_pool (i,:) = population (j, :);
break;
end
end
end
end
function [new_pop] = g_crossover (mating_pool, Pc, N, L);
parent_numrand_perm (N);
for j = 1: 2: N
pointer1 = parent_num (j);
pointer2 = parent_num (j + 1);
cut_point = randi (1,1, L);
off1 = matin_pool (pointer1, :);
off2 = mating_pool (pointer2, :);
if rand <Pc
temp = off2;
off2 (cut_point + 1: end) = off1 (cut_point + 1: end);
off1 (cut_point + 1: end) = temp (cut_point + 1: end);
end
new_pop (j,:) = off1;
new_pop (j + 1,:) = off2;
end
end
function [population] = g_mutation (new_pop, Pm, N, L);
mask = rand (N, L) <= Pm;
poulation = xor (new_pop, mask);
end
```

You need to correct the error so that I can help you

MATLAB prints a message. Leave that.

Hi

What is the reason for this error?

```
(Error using svmtrain (line230
swmtrain has been removed. use fitcsvminstead
```

Hi

In the 2015 versions, the svmtrain function has been removed and replaced by the fitcsvm function.

Hello, I need to define the dependent Legendre function in the program

```
But for plm
But I for pl, m + 1
,
Pl, m-1
I also need that my program gives an error, please show me, I really need it
My program
for l = 1: lmax
for m = 0: l
if abs (m)> l
Alm = 0;
Blm = 0;
elseif m> = 0
L = legendre (l, e, ‘norm’);
plm = L (m + 1,:,:);% Plm
Plm = squeeze (plm);
plm1 = L (m + 2,:,:);% plm + 1
Plm1 = squeeze (plm1);
plm2 = L (m,:,:);% plm-1
Plm2 = squeeze (plm2);
Error
Subscript indices must either be real positive integers or logicals.
Error in AlmBlm (line 27)
plm2 = L (m,:,:);% plm-1
Index exceeds matrix dimensions.
Error in AlmBlm (line 25)
plm1 = L (m + 2,:,:);% plm + 1
```

Hi

This is an error

Subscript indices must either be real positive integers or logicals.

That is, you are calling a cell of the array with an incorrect number, such as cell zero or cell minus 2. Because we do not have such a house, MATLAB also gives this error.

Hi

Excuse me, can you please help me?

What is this error about?

`Attempted to access W (25); index out of bounds because numel (W) = 1.`

Hi

MATLAB is telling you in a non-sweet English language:

You called the 25th cell of the W array in your code, but MATLAB gave an error because W does not have just one more cell.

Please answer

What does this error mean?

```
Cannot find an exact (case-sensitive) match for ‘createmodel’
The closest match is: Createmodel in D: \ Program Files \ MATLAB \ R2018b \ bin \ Createmodel.m
Error in saa (line 6)
model = createmodel (); % Create Problem Model
```

You order

model = createmodel ();

You called a function. MATLAB first looks for this file in the current code and then in the current path and then in its own path, and if it does not find it, it gives an error message.

In MATLAB format, it is case sensitive, meaning that uppercase and lowercase letters are different. If you want the correct function to be called, convert the small c to the large C in the command.

Please answer

What does the following error mean?

MATLAB crash file: C: \ Users \ user \ AppData \ Local \ Temp \ matlab_crash_dump.1308-1:

```
——————————————————————————
Assertion detected at Mon Nov 26 10:53:53 2018
——————————————————————————
Configuration:
Crash Decoding: Disabled - No sandbox or build area path
Crash Mode: continue (default)
Current Graphics Driver: Unknown hardware
Default Encoding: windows-1256
Deployed: false
Graphics card 1: Intel Corporation (0x8086) Intel (R) HD Graphics 510 Version 23.20.16.4973
Graphics card 2: Advanced Micro Devices, Inc. (0x1002) AMD Radeon (TM) R5 M430 Version 21.19.142.32768
Host Name: DESKTOP-PF2GNPP
Java Crash Report: C: \ Users \ user \ AppData \ Local \ Temp \ hs_error_pid1308.log
MATLAB Architecture: win64
MATLAB Entitlement ID: Unknown
MATLAB Root: C: \ Program Files \ MATLAB \ R2016b
MATLAB Version: 9.1.0.441655 (R2016b)
OpenGL: hardware
Operating System: Microsoft Windows 10 Home
Processor ID: x86 Family 6 Model 78 Stepping 3, GenuineIntel
Virtual Machine: Java 1.7.0_60-b19 with Oracle Corporation Java HotSpot (TM) 64-Bit Server VM mixed mode
Window System: Version 10.0 (Build 17134)
Fault Count: 1
Assertion in void __cdecl `anonymous-namespace ':: mwJavaAbort (void) at b: \ matlab \ src \ jmi \ jmi \ javainit.cpp line 1418:
Fatal Java Exception. See Java Crash Report for details.
Register State (captured):
RAX = 000000001085f2e8 RBX = 000000001085f2e8
RCX = 00000001841421a0 RDX = 000000000000000000
RSP = 0000000184142120 RBP = 00000000217e93b0
RSI = 000000001085f2e8 RDI = 000000000000000000
R8 = 000000000000000000 R9 = 00007fffc4fd0000
R10 = 000000001084f317 R11 = 000000001084f317
R12 = 00000000217e93b0 R13 = 00000001841427e0
R14 = 000000001084f218 R15 = 000000001085f268
RIP = 000000001068971a EFL = 00000202
CS = 0033 FS = 0053 GS = 002b
Stack Trace (captured):
[0] 0x0000000010684153 C: \ Program Files \ MATLAB \ R2016b \ bin \ win64 \ libmwfl.dll + 00082259
[1] 0x0000000010682a68 C: \ Program Files \ MATLAB \ R2016b \ bin \ win64 \ libmwfl.dll + 00076392
[2] 0x0000000010685b2a C: \ Program Files \ MATLAB \ R2016b \ bin \ win64 \ libmwfl.dll + 00088874
[3] 0x0000000010685377 C: \ Program Files \ MATLAB \ R2016b \ bin \ win64 \ libmwfl.dll + 00086903
[4] 0x0000000010689168 C: \ Program Files \ MATLAB \ R2016b \ bin \ win64 \ libmwfl.dll + 00102760
[5] 0x0000000021788c27 C: \ Program Files \ MATLAB \ R2016b \ bin \ win64 \ jmi.dll + 00691239
[6] 0x000000005e5f7b6d C: \ Program Files \ MATLAB \ R2016b \ sys \ java \ jre \ win64 \ jre \ bin \ server \ jvm.dll + 02390893
[7] 0x000000005e5e0ad8 C: \ Program Files \ MATLAB \ R2016b \ sys \ java \ jre \ win64 \ jre \ bin \ server \ jvm.dll + 02296536
[8] 0x000000005e5f88e6 C: \ Program Files \ MATLAB \ R2016b \ sys \ java \ jre \ win64 \ jre \ bin \ server \ jvm.dll + 02394342
[9] 0x000000005e5fc2d8 C: \ Program Files \ MATLAB \ R2016b \ sys \ java \ jre \ win64 \ jre \ bin \ server \ jvm.dll + 02409176
[10] 0x000000005e693a48 C: \ Program Files \ MATLAB \ R2016b \ sys \ java \ jre \ win64 \ jre \ bin \ server \ jvm.dll + 03029576
[11] 0x00007fffed87ed3d C: \ WINDOWS \ SYSTEM32 \ ntdll.dll + 00650557
[12] 0x00007fffed7e6c86 C: \ WINDOWS \ SYSTEM32 \ ntdll.dll + 00027782
[13] 0x00007fffed87dc6e C: \ WINDOWS \ SYSTEM32 \ ntdll.dll + 00646254
[14] 0x00000000f345131e C: \ WINDOWS \ System32 \ DriverStore \ FileRepository \ c0308479.inf_amd64_138bcbdfe295965a \ atio6axx.dll + 16257822
[15] 0x00000000f34512e6 C: \ WINDOWS \ System32 \ DriverStore \ FileRepository \ c0308479.inf_amd64_138bcbdfe295965a \ atio6axx.dll + 16257766
[16] 0x00000000f274ed6d C: \ WINDOWS \ System32 \ DriverStore \ FileRepository \ c0308479.inf_amd64_138bcbdfe295965a \ atio6axx.dll + 02616685
[17] 0x00000000f32bc571 C: \ WINDOWS \ System32 \ DriverStore \ FileRepository \ c0308479.inf_amd64_138bcbdfe295965a \ atio6axx.dll + 14599537
[18] 0x00000000f32bc748 C: \ WINDOWS \ System32 \ DriverStore \ FileRepository \ c0308479.inf_amd64_138bcbdfe295965a \ atio6axx.dll + 14600008
[19] 0x00000000f32bc168 C: \ WINDOWS \ System32 \ DriverStore \ FileRepository \ c0308479.inf_amd64_138bcbdfe295965a \ atio6axx.dll + 14598504
[20] 0x00000000f262194b C: \ WINDOWS \ System32 \ DriverStore \ FileRepository \ c0308479.inf_amd64_138bcbdfe295965a \ atio6axx.dll + 01382731
[21] 0x00000000f2620c77 C: \ WINDOWS \ System32 \ DriverStore \ FileRepository \ c0308479.inf_amd64_138bcbdfe295965a \ atio6axx.dll + 01379447
[22] 0x00007fffd6986cfc C: \ WINDOWS \ SYSTEM32 \ OpenGL32.dll + 00158972
[23] 0x00007fffd698710d C: \ WINDOWS \ SYSTEM32 \ OpenGL32.dll + 00160013
[24] 0x00007fffd699a209 C: \ WINDOWS \ SYSTEM32 \ OpenGL32.dll + 00238089
[25] 0x00007fffe9e07adc C: \ WINDOWS \ System32 \ gdi32full.dll + 00424668
[26] 0x00000000481d3150 +00000000
If this problem is reproducible, please submit a Service Request via:
http://www.mathworks.com/support/contact_us/
A technical support engineer might contact you with
```

solution :

Hi

Save your file and reopen MATLAB.

Hi

There is someone who can fix the error of this m-file

```
function [bbox, bbX, faces, bbfaces] = detectFaceParts (detector, X, ~)
if (nargin <3)
thick = 1;
end
bbox = step (detector.detector {5}, X);
bbsize = size (bbox);
partsNum = zeros (size (bbox, 1), 1);
Or this m-file
function dst = mergeFourPoints (src)
pos = zeros (size (src, 1), 2);
pos (:, 1) = mean (src (:, [1,3,5,7]), 2);
pos (:, 2) = mean (src (:, [2,4,6,8]), 2);
pos = horzcat (pos, [1: size (src, 1)] ');
dst = [];
while (~ isempty (pos))
if (size (pos, 1) == 1)
dst = vertcat (dst, src (pos (1,3), :));
pos = [];
else
tmp = src (pos (1,3), :);
rad = norm (pos (1,1: 2) - tmp (1,1: 2)) + norm (pos (1,1: 2) - tmp (1,3: 4)) + norm (pos (1, 1: 2) - tmp (1.5: 6)) + norm (pos (1.1: 2) - tmp (1.7: 8));
th = rad / 8;
p = 1;
for i = 2: size (pos, 1)
rad = norm (pos (1,1: 2) - pos (i, 1: 2));
if (rad 0;
tmp = sum (tmp) ./ sum (num);
dst = vertcat (dst, tmp);
pos (p, :) = [];
end
end
else
dst = src;
end
Help, thank you very much
```

Where is the problem with the following program? Thank you for your love

```
clc
clear
x = linspace (2,5,60); t = 0% 3;
for i = 1; length (t)
for j = 1; length (x)
z (j, 1) = (e ^ (- x (j)) * sin (t (i)) + 2 * x (j));
end
end
for i = 1; length (t)
temp = sprintf (‘t = 60xi = t (i)’);
subplot (2,2,1), plot (x, x (:; i) + i + e | (tem))
end
```

There can be many reasons for the program to fail.

For example, you mistyped the flowchart. We do not know this anymore, you know the purpose of your program.

`Conversion to logical from sym is not possible.`

Hello

The above error in MATLAB means what should I do ??

Thanks for your guidance

Hi

You are using symbolic variables in the program. Symbolic variables are used to express a mathematical relation and to express a formula.

You can not use them as indexes because they do not contain a number that would point to an index of an array.

If you want to use it as a number, you have to change its type to double.

Hi

What is the cause of the undefined function or variable network error in the neural network? Thankful.

Hi

This error is related to the Neural Network Toolbox license tool license, which does not execute neural network commands when MATLAB realizes that the license has a problem.

Check this command:

license (‘checkout’, ‘nntool’);

Or

“License (‘ test ’,‘ neural_network_toolbox ’)”

If the output of these is zero, it means that the problematic MATLAB is installed.

This is the first time in 14 years that I have worked for MATLAB and Neural Network that I see this error. You either downloaded the legal version and did not buy the license, but there is no problem with broken locked versions.

Hi

Excuse me, how can I fix this error, even though I defined co1 during programming, but it does not know:

Program :

```
tic
clc
clear all
format long
%%
Node_list = xlsread (‘Book1.xlsx’, ‘Sheet1 ′,’ A2: A161 ′);
Element_list = xlsread (‘Book2.xlsx’, ‘Sheet1 ′,’ A2: A132 ′);
%%
COORDINATE = xlsread (‘Book1.xlsx’, ‘Sheet1 ′,’ B2: D161 ′);
DIRECT = xlsread (‘Book2.xlsx’, ‘Sheet1 ′,’ B2: E132 ′);
FN = xlsread (‘Book3.xlsx’, ‘Sheet1 ′,’ D2: D7 ′);
A = zeros (160.2);
for k = 1: Node_list
A (:, 1) = COORDINATE (k, 1);
A (:, 2) = COORDINATE (k, 2);
end
thickness = 1.5;
E = 30e6;
P = 1500;
v = .3;
%%%%%%%
%%
K = zeros (2 * 160);
D = (E / (1- (v ^ 2))) * [1 v 0; v 1 0; 0 0 (1-v) / 2];
N_Gausspoints = 4;
s (1) = 1 / sqrt (3); t (1) = - 1 / sqrt (3); w (1) = 1;
s (2) = - 1 / sqrt (3); t (2) = 1 / sqrt (3); w (2) = 1;
s (3) = 1 / sqrt (3); t (3) = - 1 / sqrt (3); w (3) = 1;
s (4) = 1 / sqrt (3); t (4) = 1 / sqrt (3); w (4) = 1;
B = zeros (131.4);
for n = 1: Element_list
B (:, 1) = DIRECT (n, 1);
B (:, 2) = DIRECT (n, 2);
B (:, 3) = DIRECT (n, 3);
B (:, 4) = DIRECT (n, 4);
for p = 1: N_Gausspoints
% a = dy / dt & b = dy / ds & c = dx / ds & d = dx / dt
a (p) =. 25 * ((Y (co1 (n)) * (s (p) -1) + (Y (co2 (n)) * (- 1-s (p))) +…
(Y (co3 (n)) * (1 + s (p))) + (Y (co4 (n)) * (1-s (p)))));
b (p) =. 25 * ((Y (co1 (n)) * (t (p) -1)) + (Y (co2 (n)) * (1-t (p))) +…
(Y (co3 (n)) * (1 + t (p))) + (Y (co4 (n)) * (- 1-t (p))));
c (p) =. 25 * ((X (co1 (n)) * (t (p) -1)) + (X (co2 (n)) * (1-t (p))) +…
(X (co3 (n)) * (1 + t (p))) + (X (co4 (n)) * (- 1-t (p))));
d (p) =. 25 * ((X (co1 (n)) * (s (p) -1)) + (X (co2 (n)) * (- 1-s (p))) +…
(X (co3 (n)) * (1 + s (p))) + (X (co4 (n)) * (1-s (p))));
Relevant error:
Undefined function or variable ‘co1’.
Error in project2 (line 45)
a (p) =. 25 * ((Y (co1 (n)) * (s (p) -1) + (Y (co2 (n)) * (- 1-s (p))) +…
- Unfortunately, when defining functions, I also encounter similar errors, although I defined them in m-file, for example:
Undefined function or variable ‘jacobi’.
Error in project (line 44)
(jmatrix = jacobi (ss, tt, x1, y1, x2, y2, x3, y3, x4, y4;
```

Hi

So, as you say, MATLAB is working wrong and the program is right?

No program has a problem. This variable is not defined from the beginning of the program until you called co1.

Greetings and Regards

When I open the MATLAB program, I encounter the following message and it does not allow me to do anything. Thank you for your help.

```
Content is not allowed in prolog.
Could not parse the file: c: \ program files \ matlab \ r2014a \ toolbox \ control \ control \ info.xml
```

Hi

This problem is with xml files and you can not solve it with MATLAB knowledge.

Hello, do not be tired

I want to save a variable in the workspace but it shows me this message

Error using save Unable to write file gh.mat: permission denied.

Thank you for your help

Hi

It is clear that you are not allowed to change the files and do not have the necessary premise.

If you are not the system admin, log in with the admin user.

If you are not, ask the admin to activate the necessary permission for you.

Hi again, I want to run a Simulink, but it gives me an error

The current directory ‘c: \ program files \ matlab \ matlab production server \ r2015a \ bin’ is reserved for MATLAB files. Please change your current directory to a writeable directory outside of the MATLAB installation area.

What should I do to get it right ???????

Hi

Put Simulink files in a folder and then change the path of MATLAB to this folder.

Hello, do not be tired.

There is an error in the program I wrote. Can you please help me with what?

function l2 = TourLength2 (tour, model, beinpath, source, power, sinktab) n = number (tour); if n> 0 tour2 = []; for i = 1: n if beinpath (1, i) == 1 tour2 = [tour2 tour (i)]; end end tour = tour2; n = number (tour); if n> 0 D2 = zeros (1, n); D3 = zeros (1, n); % dist to sink for i = 1: n D2 (1, i) = sqrt ((model.x (tour (i)) - sinktab (1,1)) ^ 2+ (model.y (tour (i)) - sinktab (1,2)) ^ 2 ); end % dist to source for i = 1: n D3 (1, i) = sqrt ((model.x (tour (i)) - source.x) ^ 2 + (model.y (tour (i)) - source.y) ^ 2); end L = 0; for i = 1: n-1 L = L + model.D (tour (i), tour (i + 1)); if model.D (tour (i), tour (i + 1))> power L = 1000; end end L = L + D2 (1, n); if D2 (1, n)> power L = 1000; end L = L + D3 (1.1); if D3 (1,1)> power L = 1000; end l2 = 1 / (L + 1); else l2 = 0; end else l2 = 0; end end _____________ >> TourLength2 Error using TourLength2 (line 2) Not enough input arguments.

Hi

Error not enough argument

That is, you defined an article with a four-input function, and when calling, you called the function with a smaller number of inputs, and MATLAB wonders why your function has four inputs and why you entered three inputs.

TourLength2 has six inputs and you did not give it any input when calling.

Hello good time

Sorry, I defined a function whose code is as follows, but unfortunately the execution time gets the Not enough argument error. Thank you, please help. I use MATLAB 2019b. Thanks

Function code: function [f1, f2, f3] = RD (x1, x2, y1, y2) f1 = 17655 * x1 + 1114 * x2 + 74127; f2 = 26155 * x1 + 775 * x2 + 13147; f3 = 0.4721 * y1 + 0.0740 * y2;

Hi

Error not enough argument

That is, you defined an article with a four-input function, and when calling, you called the function with a smaller number of inputs, and MATLAB wonders why your function has four inputs and why you entered three inputs.

Hi, this program that I run gives the following error ————- >> HHO Plz, wait for Run HHO… Error using HHO (line 3) Not enough input arguments. ———— function [HHO_best_fitness, HHO_NFC, new_test_HHO, HHO_convergence_curve, HHO_SR, HHO_num_itr] = HHO (positions, SearchAgents_no, max_iter, lb, ub, dim, fobj, answer, Min_ErFE, MA) disp (‘Plz, wait for Run HHO…’) best_pos = zeros (1, dim); % Rabbit_Location: initialize the location and Energy of the rabbit HHO_best_fitness = inf; % Rabbit_Energy change this to -inf for maximization problems HHO_convergence_curve (1, MAX_NFFE) = 0; new_test_HHO (1: MAX_NFFE) = 0; HHO_NFC = 0; HHO_SR = 0; HHO_num_itr = 1; t = 1; % positions = positions; % Initialize the locations of Harris ’hawks % CNVG = zeros (1, T); for i = 1: SearchAgents_no fitness = abs ((fobj (positions (i, :))) - answer); % Calculate objective function for each search agent if fitness for maximization problem HHO_best_fitness = fitness; % Update alpha best_pos = positions (i, :); % Update the rabbit end if HHO_best_fitness> Min_Err HHO_NFC = HHO_NFC + 1; end HHO_convergence_curve (HHO_NFC) = HHO_best_fitness; ind_mean = mean (positions, 1); t_sum = 0; for ii = 1: SearchAgents_no k_sum = 0; for j = 1: dim k_sum = k_sum + ((positions (ii, j). ^ 2) - ((ind_mean (1, j)). ^ 2)); end t_sum = t_sum + sqrt (k_sum); end new_test_HHO (HHO_NFC) = ((1 / SearchAgents_no) * (t_sum)); end while (t <max_iter && HHO_NFC Min_Err) E1 = 2 * (1- (t / max_iter)); % factor to show the decreaing energy of rabbit % Update the location of Harris ’hawks for i = 1: size (positions, 1) E0 = 2 * rand () - 1; % -1 <E0 = 1 % Exploration: % Harris ’hawks perch randomly based on 2 strategy: q = rand (); rand_Hawk_index = floor (SearchAgents_no * rand () + 1); X_rand = positions (rand_Hawk_index, :); if q = 0.5 % perch on a random tall tree (random site inside group’s home range) positions (i,:) = (best_pos (1,:) - mean (positions)) - rand () * ((ub-lb) * rand + lb); end elseif abs (Escaping_Energy) = 0.5 && abs (Escaping_Energy) = 0.5 && abs (Escaping_Energy)> = 0.5% Soft pressure Jump_strength = 2 * (1-rand ()); % random jump strength of the rabbit positions (i,:) = (best_pos-positions (i,:)) - Escaping_Energy * abs (Jump_strength * best_pos-positions (i, :)); end % phase 2: performing team rapid dives (leapfrog movements) if r = 0.5,% Soft besiege% rabbit try to escape by many zigzag deceptive motions Jump_strength = 2 * (1-rand ()); X1 = best_pos-Escaping_Energy * abs (Jump_strength * best_pos-positions (i, :)); if fobj (X1) <fobj (positions (i, :))% improved move? positions (i,:) = X1; else% hawks perform levy-based short rapid dives around the rabbit X2 = best_pos-Escaping_Energy * abs (Jump_strength * best_pos-positions (i,:)) + rand (1, dim). * Levy (dim); if (fobj (X2) <fobj (positions (i, :))),% improved move? positions (i,:) = X2; end end end if r <0.5 && abs (Escaping_Energy) <0.5,% Hard besiege% rabbit try to escape by many zigzag deceptive motions % hawks try to decrease their average location with the rabbit Jump_strength = 2 * (1-rand ()); X1 = best_pos-Escaping_Energy * abs (Jump_strength * best_pos-mean (positions)); if fobj (X1) <fobj (positions (i, :))% improved move? positions (i,:) = X1; else% Perform levy-based short rapid dives around the rabbit X2 = best_pos-Escaping_Energy * abs (Jump_strength * best_pos-mean (positions)) + rand (1, dim). * Levy (dim); if (fobj (X2) ub; FL = positions (i,:) <lb; positions (i,:) = (positions (i,:). * (~ (FU + FL))) + ub. * FU + lb. * FL; % fitness of locations % fitness = fobj (positions (i, :)); % Update the location of Rabbit fitness = abs ((fobj (positions (i, :))) - answer); if fitness for maximization problem HHO_best_fitness = fitness; % Update alpha best_pos = positions (i, :); % Update the leaHHOr end if HHO_best_fitness> Min_Err HHO_NFC = HHO_NFC + 1; end HHO_convergence_curve (HHO_NFC) = HHO_best_fitness; ind_mean = mean (positions, 1); t_sum = 0; for ii = 1: SearchAgents_no k_sum = 0; for j = 1: dim k_sum = k_sum + ((positions (ii, j). ^ 2) - ((ind_mean (1, j)). ^ 2)); end t_sum = t_sum + sqrt (k_sum); end new_test_HHO (HHO_NFC) = ((1 / SearchAgents_no) * (t_sum)); end t = t + 1; HHO_num_itr = t; % CNVG (t) = HHO_best_fitness; % Print the progress every 100 iterations % if mod (t, 100) == 0 % display ([‘At iteration’, num2str (t), ‘the best fitness is’, num2str (Rabbit_Energy)]); % end end if HHO_NFC <MAX_NFFE HHO_SR = 1; end disp (HHO_best_fitness) % toc end function o = Levy (d) beta = 1.5; sigma = (gamma (1 + beta) * sin (pi * beta / 2) / (gamma ((1 + beta) / 2) * beta * 2 ^ ((beta-1) / 2))) ^ (1 / beta); u = randn (1, d) * sigma; v = randn (1, d); step = u. / abs (v). ^ (1 / beta); o = step; end

Error

Not enough input arguments

That is, you are calling a function, but the desired function has, for example, three inputs, but you are giving it 2 inputs.

x = gallery (‘uniformdata’, 30,1,1); y = gallery (‘uniformdata’, 30,1,10); plot (x, y, ’.’) xlim ([- 0.2 1.2]) ylim ([- 0.2 1.2]) k = boundary (x, y); hold on; plot (x (k), y (k));

I wanted to see what the problem is with this code

Hi

No specific bugs were found in the code but you can open the variable k and see if it is an array. Because it is used for indexing, it must be a numeric array.

Also see MATLAB commands in the counter field, it might be better than the method you chose.