Tag Archives: matlab
Hi, I need help with coding for large expressions with integrations as given in the image.
I m kind of new to Matlab with average level expertise. Can anybody pls provide code for these or similar equations and then I modify according to these. I have used the integral function in coding for these but all I get is an empty graph with no trend. and NaN. Your guidance/help will be highly appreciated. Thanks
The PrL (u) is the LoS probability function, which is
and theta is
Another equation is
,, Again the PL(v) is the LoS probabilityI m kind of new to Matlab with average level expertise. Can anybody pls provide code for these or similar equations and then I modify according to these. I have used the integral function in coding for these but all I get is an empty graph with no trend. and NaN. Your guidance/help will be highly appreciated. Thanks
The PrL (u) is the LoS probability function, which is
and theta is
Another equation is
,, Again the PL(v) is the LoS probability I m kind of new to Matlab with average level expertise. Can anybody pls provide code for these or similar equations and then I modify according to these. I have used the integral function in coding for these but all I get is an empty graph with no trend. and NaN. Your guidance/help will be highly appreciated. Thanks
The PrL (u) is the LoS probability function, which is
and theta is
Another equation is
,, Again the PL(v) is the LoS probability wireless communications, integral, numerical integration, integration, coverage probability, statistics MATLAB Answers — New Questions
Equivalent of passing structure to “varargin” for the new “Function Argument Validation” introduced in 2019b
I have a compatibility question about the new method of adding name-value pairs to functions introduced in MATLAB 2019b as discussed on this help page. I think the new argument validation tools are very powerful and easier to use, but there’s a special use case for varargin and inputParser that I can’t get to work.
Background
In previous versions of MATLAB, I’ve used varargin with inputparser to enable name-value pairs in functions. I only used these as optional arguments, so they were always at the end of my function signature and I only used addParameters. With inputParser, I am able to pass either the variables in, or a structure with field names that correspond to the variables. For the sample function:
function demo(varargin)
% Parse the input.
p = inputParser;
p.addParameter(‘param1’,1.5);
p.addParameter(‘param2’,-8);
p.addParameter(‘param2’,17);
p.parse(varargin{:});
% Rest of function.
…
end
I could call it like this:
demo(‘param1′,7,’param2′,8,’param3’,9);
Or, to make the function call more compact, I could call it like this:
S.param1 = 7;
S.param2 = 8;
S.param3 = 9;
demo(S);
With the second method, inputParser would interpret the fields of the structure as the name-value pairs.
Question
With the new function argument validation tools, I can eliminate the need for varargin and inputparser and use the built in tools:
function demo(NameValueArgs)
arguments
NameValueArgs.param1 = 1.5;
NameValueArgs.param2 = -8;
NameValueArgs.param3 = 17;
end
% Rest of function.
…
end
However, I can’t pass a structure with the name value pairs like I can with varargin and inputparser, it produces an error.
Is there a way to get the "old" functionality back using the new arguments feature of functions? For functions with many name-value pairs, the function calls can get very long otherwise.
Thanks in advance!
-NateI have a compatibility question about the new method of adding name-value pairs to functions introduced in MATLAB 2019b as discussed on this help page. I think the new argument validation tools are very powerful and easier to use, but there’s a special use case for varargin and inputParser that I can’t get to work.
Background
In previous versions of MATLAB, I’ve used varargin with inputparser to enable name-value pairs in functions. I only used these as optional arguments, so they were always at the end of my function signature and I only used addParameters. With inputParser, I am able to pass either the variables in, or a structure with field names that correspond to the variables. For the sample function:
function demo(varargin)
% Parse the input.
p = inputParser;
p.addParameter(‘param1’,1.5);
p.addParameter(‘param2’,-8);
p.addParameter(‘param2’,17);
p.parse(varargin{:});
% Rest of function.
…
end
I could call it like this:
demo(‘param1′,7,’param2′,8,’param3’,9);
Or, to make the function call more compact, I could call it like this:
S.param1 = 7;
S.param2 = 8;
S.param3 = 9;
demo(S);
With the second method, inputParser would interpret the fields of the structure as the name-value pairs.
Question
With the new function argument validation tools, I can eliminate the need for varargin and inputparser and use the built in tools:
function demo(NameValueArgs)
arguments
NameValueArgs.param1 = 1.5;
NameValueArgs.param2 = -8;
NameValueArgs.param3 = 17;
end
% Rest of function.
…
end
However, I can’t pass a structure with the name value pairs like I can with varargin and inputparser, it produces an error.
Is there a way to get the "old" functionality back using the new arguments feature of functions? For functions with many name-value pairs, the function calls can get very long otherwise.
Thanks in advance!
-Nate I have a compatibility question about the new method of adding name-value pairs to functions introduced in MATLAB 2019b as discussed on this help page. I think the new argument validation tools are very powerful and easier to use, but there’s a special use case for varargin and inputParser that I can’t get to work.
Background
In previous versions of MATLAB, I’ve used varargin with inputparser to enable name-value pairs in functions. I only used these as optional arguments, so they were always at the end of my function signature and I only used addParameters. With inputParser, I am able to pass either the variables in, or a structure with field names that correspond to the variables. For the sample function:
function demo(varargin)
% Parse the input.
p = inputParser;
p.addParameter(‘param1’,1.5);
p.addParameter(‘param2’,-8);
p.addParameter(‘param2’,17);
p.parse(varargin{:});
% Rest of function.
…
end
I could call it like this:
demo(‘param1′,7,’param2′,8,’param3’,9);
Or, to make the function call more compact, I could call it like this:
S.param1 = 7;
S.param2 = 8;
S.param3 = 9;
demo(S);
With the second method, inputParser would interpret the fields of the structure as the name-value pairs.
Question
With the new function argument validation tools, I can eliminate the need for varargin and inputparser and use the built in tools:
function demo(NameValueArgs)
arguments
NameValueArgs.param1 = 1.5;
NameValueArgs.param2 = -8;
NameValueArgs.param3 = 17;
end
% Rest of function.
…
end
However, I can’t pass a structure with the name value pairs like I can with varargin and inputparser, it produces an error.
Is there a way to get the "old" functionality back using the new arguments feature of functions? For functions with many name-value pairs, the function calls can get very long otherwise.
Thanks in advance!
-Nate inputparser, varargin, function argument validation, arguments MATLAB Answers — New Questions
Multiple MPC Controllers: How to set the initial values of the manipulated variables?
Hello,
i have 12 MPC-Controllers, each one with manipulated variables:
u1: pump speed
u2 valve opening
The output variable of the system is temperature.
I am switching between the MPCs using the Multiple MPC Controllers block (https://www.mathworks.com/help/mpc/ref/multiplempccontrollers.html)
The manipulated variables should start with inital values of u1 = 2500 RPM and u2 = 0.5 mm, but both start with 0.
Any idea how to do change the initial values of the manipulated variables?
Thanks!
MartinHello,
i have 12 MPC-Controllers, each one with manipulated variables:
u1: pump speed
u2 valve opening
The output variable of the system is temperature.
I am switching between the MPCs using the Multiple MPC Controllers block (https://www.mathworks.com/help/mpc/ref/multiplempccontrollers.html)
The manipulated variables should start with inital values of u1 = 2500 RPM and u2 = 0.5 mm, but both start with 0.
Any idea how to do change the initial values of the manipulated variables?
Thanks!
Martin Hello,
i have 12 MPC-Controllers, each one with manipulated variables:
u1: pump speed
u2 valve opening
The output variable of the system is temperature.
I am switching between the MPCs using the Multiple MPC Controllers block (https://www.mathworks.com/help/mpc/ref/multiplempccontrollers.html)
The manipulated variables should start with inital values of u1 = 2500 RPM and u2 = 0.5 mm, but both start with 0.
Any idea how to do change the initial values of the manipulated variables?
Thanks!
Martin multiple mpc controllers MATLAB Answers — New Questions
How to implement importing data from csv file in optimization algorithm?
Hi,
I have attached the code used for PSO algorithm for 3D box packing. I am finding difficulty to modify the code to integrate with importing data from ‘presents.csv’ and also provide best solution for arrangements of the boxes on the grid, for example as ’50 – GA (10-Apr-2024 03.48.47).csv’.
please do share some ideas on this. thanks.
pso.m
%
% Copyright (c) 2015, Yarpiz (www.yarpiz.com)
% All rights reserved. Please read the "license.txt" for license terms.
%
% Project Code: YPAP105
% Project Title: Solving Bin Packing Problem using PSO, FA and IWO
% Publisher: Yarpiz (www.yarpiz.com)
%
% Developer: S. Mostapha Kalami Heris (Member of Yarpiz Team)
%
% Contact Info: sm.kalami@gmail.com, info@yarpiz.com
%
clc;
clear;
close all;
%% Problem Definition
model = CreateModel(); % Create Bin Packing Model
CostFunction = @(x) BinPackingCost(x, model); % Objective Function
nVar = 2*model.n-1; % Number of Decision Variables
VarSize = [1 nVar]; % Decision Variables Matrix Size
VarMin = 0; % Lower Bound of Decision Variables
VarMax = 1; % Upper Bound of Decision Variables
%% PSO Parameters
MaxIt=1000; % Maximum Number of Iterations
nPop=50; % Population Size (Swarm Size)
% PSO Parameters
w=1; % Inertia Weight
wdamp=0.99; % Inertia Weight Damping Ratio
c1=1.5; % Personal Learning Coefficient
c2=2.0; % Global Learning Coefficient
% If you would like to use Constriction Coefficients for PSO,
% uncomment the following block and comment the above set of parameters.
% % Constriction Coefficients
% phi1=2.05;
% phi2=2.05;
% phi=phi1+phi2;
% chi=2/(phi-2+sqrt(phi^2-4*phi));
% w=chi; % Inertia Weight
% wdamp=1; % Inertia Weight Damping Ratio
% c1=chi*phi1; % Personal Learning Coefficient
% c2=chi*phi2; % Global Learning Coefficient
% Velocity Limits
VelMax=0.1*(VarMax-VarMin);
VelMin=-VelMax;
nParticleMutation = 2; % Number of Mutations Performed on Each Particle
nGlobalBestMutation = 5; % Number of Mutations Performed on Global Best
%% Initialization
empty_particle.Position=[];
empty_particle.Cost=[];
empty_particle.Sol=[];
empty_particle.Velocity=[];
empty_particle.Best.Position=[];
empty_particle.Best.Cost=[];
empty_particle.Best.Sol=[];
particle=repmat(empty_particle,nPop,1);
GlobalBest.Cost=inf;
for i=1:nPop
% Initialize Position
particle(i).Position=unifrnd(VarMin,VarMax,VarSize);
% Initialize Velocity
particle(i).Velocity=zeros(VarSize);
% Evaluation
[particle(i).Cost, particle(i).Sol]=CostFunction(particle(i).Position);
% Update Personal Best
particle(i).Best.Position=particle(i).Position;
particle(i).Best.Cost=particle(i).Cost;
particle(i).Best.Sol=particle(i).Sol;
% Update Global Best
if particle(i).Best.Cost<GlobalBest.Cost
GlobalBest=particle(i).Best;
end
end
BestCost=zeros(MaxIt,1);
%% PSO Main Loop
for it=1:MaxIt
for i=1:nPop
% Update Velocity
particle(i).Velocity = w*particle(i).Velocity …
+c1*rand(VarSize).*(particle(i).Best.Position-particle(i).Position) …
+c2*rand(VarSize).*(GlobalBest.Position-particle(i).Position);
% Apply Velocity Limits
particle(i).Velocity = max(particle(i).Velocity,VelMin);
particle(i).Velocity = min(particle(i).Velocity,VelMax);
% Update Position
particle(i).Position = particle(i).Position + particle(i).Velocity;
% Velocity Mirror Effect
IsOutside=(particle(i).Position<VarMin | particle(i).Position>VarMax);
particle(i).Velocity(IsOutside)=-particle(i).Velocity(IsOutside);
% Apply Position Limits
particle(i).Position = max(particle(i).Position,VarMin);
particle(i).Position = min(particle(i).Position,VarMax);
% Evaluation
[particle(i).Cost, particle(i).Sol] = CostFunction(particle(i).Position);
% Perform Mutation
for j=1:nParticleMutation
NewParticle = particle(i);
NewParticle.Position = Mutate(particle(i).Position);
[NewParticle.Cost, NewParticle.Sol] = CostFunction(NewParticle.Position);
if NewParticle.Cost <= particle(i).Cost
particle(i) = NewParticle;
end
end
% Update Personal Best
if particle(i).Cost<particle(i).Best.Cost
particle(i).Best.Position=particle(i).Position;
particle(i).Best.Cost=particle(i).Cost;
particle(i).Best.Sol=particle(i).Sol;
% Update Global Best
if particle(i).Best.Cost<GlobalBest.Cost
GlobalBest=particle(i).Best;
end
end
end
% Perform Mutation on Global Best
for i=1:nGlobalBestMutation
NewParticle = GlobalBest;
NewParticle.Position = Mutate(GlobalBest.Position);
[NewParticle.Cost, NewParticle.Sol] = CostFunction(NewParticle.Position);
if NewParticle.Cost <= GlobalBest.Cost
GlobalBest = NewParticle;
end
end
BestCost(it)=GlobalBest.Cost;
disp([‘Iteration ‘ num2str(it) ‘: Best Cost = ‘ num2str(BestCost(it))]);
w=w*wdamp;
end
BestSol = GlobalBest;
%% Results
figure;
plot(BestCost,’LineWidth’,2);
xlabel(‘Iteration’);
ylabel(‘Best Cost’);
grid on;Hi,
I have attached the code used for PSO algorithm for 3D box packing. I am finding difficulty to modify the code to integrate with importing data from ‘presents.csv’ and also provide best solution for arrangements of the boxes on the grid, for example as ’50 – GA (10-Apr-2024 03.48.47).csv’.
please do share some ideas on this. thanks.
pso.m
%
% Copyright (c) 2015, Yarpiz (www.yarpiz.com)
% All rights reserved. Please read the "license.txt" for license terms.
%
% Project Code: YPAP105
% Project Title: Solving Bin Packing Problem using PSO, FA and IWO
% Publisher: Yarpiz (www.yarpiz.com)
%
% Developer: S. Mostapha Kalami Heris (Member of Yarpiz Team)
%
% Contact Info: sm.kalami@gmail.com, info@yarpiz.com
%
clc;
clear;
close all;
%% Problem Definition
model = CreateModel(); % Create Bin Packing Model
CostFunction = @(x) BinPackingCost(x, model); % Objective Function
nVar = 2*model.n-1; % Number of Decision Variables
VarSize = [1 nVar]; % Decision Variables Matrix Size
VarMin = 0; % Lower Bound of Decision Variables
VarMax = 1; % Upper Bound of Decision Variables
%% PSO Parameters
MaxIt=1000; % Maximum Number of Iterations
nPop=50; % Population Size (Swarm Size)
% PSO Parameters
w=1; % Inertia Weight
wdamp=0.99; % Inertia Weight Damping Ratio
c1=1.5; % Personal Learning Coefficient
c2=2.0; % Global Learning Coefficient
% If you would like to use Constriction Coefficients for PSO,
% uncomment the following block and comment the above set of parameters.
% % Constriction Coefficients
% phi1=2.05;
% phi2=2.05;
% phi=phi1+phi2;
% chi=2/(phi-2+sqrt(phi^2-4*phi));
% w=chi; % Inertia Weight
% wdamp=1; % Inertia Weight Damping Ratio
% c1=chi*phi1; % Personal Learning Coefficient
% c2=chi*phi2; % Global Learning Coefficient
% Velocity Limits
VelMax=0.1*(VarMax-VarMin);
VelMin=-VelMax;
nParticleMutation = 2; % Number of Mutations Performed on Each Particle
nGlobalBestMutation = 5; % Number of Mutations Performed on Global Best
%% Initialization
empty_particle.Position=[];
empty_particle.Cost=[];
empty_particle.Sol=[];
empty_particle.Velocity=[];
empty_particle.Best.Position=[];
empty_particle.Best.Cost=[];
empty_particle.Best.Sol=[];
particle=repmat(empty_particle,nPop,1);
GlobalBest.Cost=inf;
for i=1:nPop
% Initialize Position
particle(i).Position=unifrnd(VarMin,VarMax,VarSize);
% Initialize Velocity
particle(i).Velocity=zeros(VarSize);
% Evaluation
[particle(i).Cost, particle(i).Sol]=CostFunction(particle(i).Position);
% Update Personal Best
particle(i).Best.Position=particle(i).Position;
particle(i).Best.Cost=particle(i).Cost;
particle(i).Best.Sol=particle(i).Sol;
% Update Global Best
if particle(i).Best.Cost<GlobalBest.Cost
GlobalBest=particle(i).Best;
end
end
BestCost=zeros(MaxIt,1);
%% PSO Main Loop
for it=1:MaxIt
for i=1:nPop
% Update Velocity
particle(i).Velocity = w*particle(i).Velocity …
+c1*rand(VarSize).*(particle(i).Best.Position-particle(i).Position) …
+c2*rand(VarSize).*(GlobalBest.Position-particle(i).Position);
% Apply Velocity Limits
particle(i).Velocity = max(particle(i).Velocity,VelMin);
particle(i).Velocity = min(particle(i).Velocity,VelMax);
% Update Position
particle(i).Position = particle(i).Position + particle(i).Velocity;
% Velocity Mirror Effect
IsOutside=(particle(i).Position<VarMin | particle(i).Position>VarMax);
particle(i).Velocity(IsOutside)=-particle(i).Velocity(IsOutside);
% Apply Position Limits
particle(i).Position = max(particle(i).Position,VarMin);
particle(i).Position = min(particle(i).Position,VarMax);
% Evaluation
[particle(i).Cost, particle(i).Sol] = CostFunction(particle(i).Position);
% Perform Mutation
for j=1:nParticleMutation
NewParticle = particle(i);
NewParticle.Position = Mutate(particle(i).Position);
[NewParticle.Cost, NewParticle.Sol] = CostFunction(NewParticle.Position);
if NewParticle.Cost <= particle(i).Cost
particle(i) = NewParticle;
end
end
% Update Personal Best
if particle(i).Cost<particle(i).Best.Cost
particle(i).Best.Position=particle(i).Position;
particle(i).Best.Cost=particle(i).Cost;
particle(i).Best.Sol=particle(i).Sol;
% Update Global Best
if particle(i).Best.Cost<GlobalBest.Cost
GlobalBest=particle(i).Best;
end
end
end
% Perform Mutation on Global Best
for i=1:nGlobalBestMutation
NewParticle = GlobalBest;
NewParticle.Position = Mutate(GlobalBest.Position);
[NewParticle.Cost, NewParticle.Sol] = CostFunction(NewParticle.Position);
if NewParticle.Cost <= GlobalBest.Cost
GlobalBest = NewParticle;
end
end
BestCost(it)=GlobalBest.Cost;
disp([‘Iteration ‘ num2str(it) ‘: Best Cost = ‘ num2str(BestCost(it))]);
w=w*wdamp;
end
BestSol = GlobalBest;
%% Results
figure;
plot(BestCost,’LineWidth’,2);
xlabel(‘Iteration’);
ylabel(‘Best Cost’);
grid on; Hi,
I have attached the code used for PSO algorithm for 3D box packing. I am finding difficulty to modify the code to integrate with importing data from ‘presents.csv’ and also provide best solution for arrangements of the boxes on the grid, for example as ’50 – GA (10-Apr-2024 03.48.47).csv’.
please do share some ideas on this. thanks.
pso.m
%
% Copyright (c) 2015, Yarpiz (www.yarpiz.com)
% All rights reserved. Please read the "license.txt" for license terms.
%
% Project Code: YPAP105
% Project Title: Solving Bin Packing Problem using PSO, FA and IWO
% Publisher: Yarpiz (www.yarpiz.com)
%
% Developer: S. Mostapha Kalami Heris (Member of Yarpiz Team)
%
% Contact Info: sm.kalami@gmail.com, info@yarpiz.com
%
clc;
clear;
close all;
%% Problem Definition
model = CreateModel(); % Create Bin Packing Model
CostFunction = @(x) BinPackingCost(x, model); % Objective Function
nVar = 2*model.n-1; % Number of Decision Variables
VarSize = [1 nVar]; % Decision Variables Matrix Size
VarMin = 0; % Lower Bound of Decision Variables
VarMax = 1; % Upper Bound of Decision Variables
%% PSO Parameters
MaxIt=1000; % Maximum Number of Iterations
nPop=50; % Population Size (Swarm Size)
% PSO Parameters
w=1; % Inertia Weight
wdamp=0.99; % Inertia Weight Damping Ratio
c1=1.5; % Personal Learning Coefficient
c2=2.0; % Global Learning Coefficient
% If you would like to use Constriction Coefficients for PSO,
% uncomment the following block and comment the above set of parameters.
% % Constriction Coefficients
% phi1=2.05;
% phi2=2.05;
% phi=phi1+phi2;
% chi=2/(phi-2+sqrt(phi^2-4*phi));
% w=chi; % Inertia Weight
% wdamp=1; % Inertia Weight Damping Ratio
% c1=chi*phi1; % Personal Learning Coefficient
% c2=chi*phi2; % Global Learning Coefficient
% Velocity Limits
VelMax=0.1*(VarMax-VarMin);
VelMin=-VelMax;
nParticleMutation = 2; % Number of Mutations Performed on Each Particle
nGlobalBestMutation = 5; % Number of Mutations Performed on Global Best
%% Initialization
empty_particle.Position=[];
empty_particle.Cost=[];
empty_particle.Sol=[];
empty_particle.Velocity=[];
empty_particle.Best.Position=[];
empty_particle.Best.Cost=[];
empty_particle.Best.Sol=[];
particle=repmat(empty_particle,nPop,1);
GlobalBest.Cost=inf;
for i=1:nPop
% Initialize Position
particle(i).Position=unifrnd(VarMin,VarMax,VarSize);
% Initialize Velocity
particle(i).Velocity=zeros(VarSize);
% Evaluation
[particle(i).Cost, particle(i).Sol]=CostFunction(particle(i).Position);
% Update Personal Best
particle(i).Best.Position=particle(i).Position;
particle(i).Best.Cost=particle(i).Cost;
particle(i).Best.Sol=particle(i).Sol;
% Update Global Best
if particle(i).Best.Cost<GlobalBest.Cost
GlobalBest=particle(i).Best;
end
end
BestCost=zeros(MaxIt,1);
%% PSO Main Loop
for it=1:MaxIt
for i=1:nPop
% Update Velocity
particle(i).Velocity = w*particle(i).Velocity …
+c1*rand(VarSize).*(particle(i).Best.Position-particle(i).Position) …
+c2*rand(VarSize).*(GlobalBest.Position-particle(i).Position);
% Apply Velocity Limits
particle(i).Velocity = max(particle(i).Velocity,VelMin);
particle(i).Velocity = min(particle(i).Velocity,VelMax);
% Update Position
particle(i).Position = particle(i).Position + particle(i).Velocity;
% Velocity Mirror Effect
IsOutside=(particle(i).Position<VarMin | particle(i).Position>VarMax);
particle(i).Velocity(IsOutside)=-particle(i).Velocity(IsOutside);
% Apply Position Limits
particle(i).Position = max(particle(i).Position,VarMin);
particle(i).Position = min(particle(i).Position,VarMax);
% Evaluation
[particle(i).Cost, particle(i).Sol] = CostFunction(particle(i).Position);
% Perform Mutation
for j=1:nParticleMutation
NewParticle = particle(i);
NewParticle.Position = Mutate(particle(i).Position);
[NewParticle.Cost, NewParticle.Sol] = CostFunction(NewParticle.Position);
if NewParticle.Cost <= particle(i).Cost
particle(i) = NewParticle;
end
end
% Update Personal Best
if particle(i).Cost<particle(i).Best.Cost
particle(i).Best.Position=particle(i).Position;
particle(i).Best.Cost=particle(i).Cost;
particle(i).Best.Sol=particle(i).Sol;
% Update Global Best
if particle(i).Best.Cost<GlobalBest.Cost
GlobalBest=particle(i).Best;
end
end
end
% Perform Mutation on Global Best
for i=1:nGlobalBestMutation
NewParticle = GlobalBest;
NewParticle.Position = Mutate(GlobalBest.Position);
[NewParticle.Cost, NewParticle.Sol] = CostFunction(NewParticle.Position);
if NewParticle.Cost <= GlobalBest.Cost
GlobalBest = NewParticle;
end
end
BestCost(it)=GlobalBest.Cost;
disp([‘Iteration ‘ num2str(it) ‘: Best Cost = ‘ num2str(BestCost(it))]);
w=w*wdamp;
end
BestSol = GlobalBest;
%% Results
figure;
plot(BestCost,’LineWidth’,2);
xlabel(‘Iteration’);
ylabel(‘Best Cost’);
grid on; 3d, matlab, box packing, optimization, algorithm, plot MATLAB Answers — New Questions
getting errors in ic tester code
Dot indexing is not supported for variables of this type.
Error in ic_tester>popupmenu1_CreateFcn (line 116)
set(handles.text2, ‘String’, ‘Please select an option from the dropdown’);
Error in gui_mainfcn (line 95)
feval(varargin{:});
Error in ic_tester (line 41)
gui_mainfcn(gui_State, varargin{:});
Error in matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)ic_tester(‘popupmenu1_CreateFcn’,hObject,eventdata,guidata(hObject))
im getting these errors while running my ic tester code
below is my code from ic_tester.m file
function varargout = ic_tester(varargin)
% IC_TESTER MATLAB code for ic_tester.fig
% IC_TESTER, by itself, creates a new IC_TESTER or raises the existing
% singleton*.
%
% H = IC_TESTER returns the handle to a new IC_TESTER or the handle to
% the existing singleton*.
%
% IC_TESTER(‘CALLBACK’,hObject,eventData,handles,…) calls the local
% function named CALLBACK in IC_TESTER.M with the given input arguments.
%
% IC_TESTER(‘Property’,’Value’,…) creates a new IC_TESTER or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before ic_tester_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to ic_tester_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE’s Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Last Modified by GUIDE v2.5 27-Nov-2016 17:28:30
% Begin initialization code – DO NOT EDIT
gui_Singleton = 1;
gui_State = struct(‘gui_Name’, mfilename, …
‘gui_Singleton’, gui_Singleton, …
‘gui_OpeningFcn’, @ic_tester_OpeningFcn, …
‘gui_OutputFcn’, @ic_tester_OutputFcn, …
‘gui_LayoutFcn’, [] , …
‘gui_Callback’, []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code – DO NOT EDIT
end
function ic_tester_OpeningFcn(hObject, ~, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved – to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to ic_tester (see VARARGIN)
% Choose default command line output for ic_tester
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
set(handles.text2, ‘String’, ‘Welcome! Click on "Connect" to start’);
end
function varargout = ic_tester_OutputFcn(~, ~, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved – to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.output;
end
function connectToArduino(handles)
try
handles.a = arduino(‘COM8’);
set(handles.text2, ‘String’, ‘Connected’);
catch
set(handles.text2, ‘String’, ‘Failed to connect to Arduino’);
end
end
function pushbutton1_Callback(~, ~, handles)
set(handles.text2, ‘String’, ‘Connecting…’);
connectToArduino(handles);
end
function popupmenu1_CreateFcn(hObject, ~, handles)
% hObject handle to popupmenu1 (see GCBO)
% eventdata reserved – to be defined in a future version of MATLAB
% handles empty – handles not created until after all CreateFcns called
% Hint: popupmenu controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,’BackgroundColor’), get(0,’defaultUicontrolBackgroundColor’))
set(hObject,’BackgroundColor’,’white’);
end
function pushbutton2_Callback(~, ~, handles)
if ~isfield(handles, ‘a’)
set(handles.text2, ‘String’, ‘Arduino not connected’);
return;
end
end
global n;
if isempty(n)
set(handles.text2, ‘String’, ‘Please select an option from the dropdown’);
return;
end
try
a = handles.a;
switch n
case 1
% Your logic for case 1 here
a.pinMode(2,’output’); % Changed from 13 to 2
a.pinMode(3,’output’);
a.pinMode(4,’input’); % Changed from 2 to 3
a.pinMode(5,’output’);
a.pinMode(6,’input’); % Changed from 3 to 4
a.pinMode(7,’input’);
a.pinMode(8,’output’);
a.pinMode(9,’output’);
a.pinMode(10,’input’);
a.pinMode(11,’output’);
a.pinMode(12,’output’);
a.digitalWrite(2,0);
a.digitalWrite(3,0);
a.digitalWrite(5,0);
a.digitalWrite(8,0);
a.digitalWrite(9,0);
a.digitalWrite(11,0);
a.digitalWrite(12,0);
pause(0.1);
t11=a.digitalRead(4);
t12=a.digitalRead(6);
t13=a.digitalRead(7);
t14=a.digitalRead(10);
if (t11==1 && t12==1 && t13==1 && t14==1)
a.digitalWrite(2,1);
a.digitalWrite(3,1);
a.digitalWrite(5,1);
a.digitalWrite(8,1);
a.digitalWrite(9,1);
a.digitalWrite(11,1);
a.digitalWrite(12,1);
pause(0.1);
t21=a.digitalRead(4);
t22=a.digitalRead(6);
t23=a.digitalRead(7);
t24=a.digitalRead(10);
if (t21==0 && t22==0 && t23==0 && t24==0)
set(handles.text2,’String’,’IC is in working condition’);
else
set(handles.text2,’String’,’Faulty IC’);
end
else
set(handles.text2,’String’,’Faulty IC’);
end
case 2
% Your logic for case 2 here
a.pinMode(13,’input’);
a.pinMode(2,’output’);
a.pinMode(3,’output’);
a.pinMode(4,’input’);
a.pinMode(5,’output’);
a.pinMode(6,’output’);
a.pinMode(7,’output’);
a.pinMode(8,’output’);
a.pinMode(9,’input’);
a.pinMode(10,’output’);
a.pinMode(11,’output’);
a.pinMode(12,’input’);
a.digitalWrite(2,0);
a.digitalWrite(3,0);
a.digitalWrite(5,0);
a.digitalWrite(6,0);
a.digitalWrite(7,0);
a.digitalWrite(8,0);
a.digitalWrite(10,0);
a.digitalWrite(11,0);
pause(0.1);
t11=a.digitalRead(13);
t12=a.digitalRead(4);
t13=a.digitalRead(9);
t14=a.digitalRead(12);
if (t11==1 && t12==1 && t13==1 && t14==1)
a.digitalWrite(2,0);
a.digitalWrite(3,1);
a.digitalWrite(5,0);
a.digitalWrite(6,1);
a.digitalWrite(7,0);
a.digitalWrite(8,1);
a.digitalWrite(10,0);
a.digitalWrite(11,1);
pause(0.1);
t21=a.digitalRead(13);
t22=a.digitalRead(4);
t23=a.digitalRead(9);
t24=a.digitalRead(12);
if (t21==0 && t22==0 && t23==0 && t24==0)
a.digitalWrite(2,1);
a.digitalWrite(3,0);
a.digitalWrite(5,1);
a.digitalWrite(6,0);
a.digitalWrite(7,1);
a.digitalWrite(8,0);
a.digitalWrite(10,1);
a.digitalWrite(11,0);
pause(0.1);
t31=a.digitalRead(13);
t32=a.digitalRead(4);
t33=a.digitalRead(9);
t34=a.digitalRead(12);
if (t31==0 && t32==0 && t33==0 && t34==0)
a.digitalWrite(2,1);
a.digitalWrite(3,1);
a.digitalWrite(5,1);
a.digitalWrite(6,1);
a.digitalWrite(7,1);
a.digitalWrite(8,1);
a.digitalWrite(10,1);
a.digitalWrite(11,1);
pause(0.1);
t41=a.digitalRead(13);
t42=a.digitalRead(4);
t43=a.digitalRead(9);
t44=a.digitalRead(12);
if (t41==0 && t42==0 && t43==0 && t44==0)
set(handles.text2,’String’,’IC is in working condition’);
else
set(handles.text2,’String’,’Faulty IC’);
end
else
set(handles.text2,’String’,’Faulty IC’);
end
else
set(handles.text2,’String’,’Faulty IC’);
end
else
set(handles.text2,’String’,’Faulty IC’);
end
case 3
% Your logic for case 3 here
a.pinMode(13,’output’);
a.pinMode(2,’input’);
a.pinMode(3,’output’);
a.pinMode(4,’input’);
a.pinMode(5,’output’);
a.pinMode(6,’input’);
a.pinMode(7,’input’);
a.pinMode(8,’output’);
a.pinMode(9,’input’);
a.pinMode(10,’output’);
a.pinMode(11,’input’);
a.pinMode(12,’output’);
a.digitalWrite(13,1);
a.digitalWrite(3,1);
a.digitalWrite(5,1);
a.digitalWrite(8,1);
a.digitalWrite(10,1);
a.digitalWrite(12,1);
pause(0.1);
t11=a.digitalRead(2);
t12=a.digitalRead(4);
t13=a.digitalRead(6);
t14=a.digitalRead(7);
t15=a.digitalRead(9);
t16=a.digitalRead(11);
if (t11==0 && t12==0 && t13==0 && t14==0 && t15==0 && t16==0)
a.digitalWrite(13,0);
a.digitalWrite(3,0);
a.digitalWrite(5,0);
a.digitalWrite(8,0);
a.digitalWrite(10,0);
a.digitalWrite(12,0);
pause(0.1);
t11=a.digitalRead(2);
t12=a.digitalRead(4);
t13=a.digitalRead(6);
t14=a.digitalRead(7);
t15=a.digitalRead(9);
t16=a.digitalRead(11);
if (t11==1 && t12==1 && t13==1 && t14==1 && t15==1 && t16==1)
set(handles.text2,’String’,’IC is in working condition’);
else
set(handles.text2,’String’,’Faulty IC’);
end
else
set(handles.text2,’String’,’Faulty IC’);
end
case 4
% Your logic for case 4 here
a.pinMode(13,’output’);
a.pinMode(2,’output’);
a.pinMode(3,’input’);
a.pinMode(4,’output’);
a.pinMode(5,’output’);
a.pinMode(6,’input’);
a.pinMode(7,’input’);
a.pinMode(8,’output’);
a.pinMode(9,’output’);
a.pinMode(10,’input’);
a.pinMode(11,’output’);
a.pinMode(12,’output’);
a.digitalWrite(13,0);
a.digitalWrite(2,0);
a.digitalWrite(4,0);
a.digitalWrite(5,0);
a.digitalWrite(8,0);
a.digitalWrite(9,0);
a.digitalWrite(11,0);
a.digitalWrite(12,0);
pause(0.1);
t11=a.digitalRead(3);
t12=a.digitalRead(6);
t13=a.digitalRead(7);
t14=a.digitalRead(10);
if (t11==0 && t12==0 && t13==0 && t14==0)
a.digitalWrite(13,0);
a.digitalWrite(2,1);
a.digitalWrite(4,0);
a.digitalWrite(5,1);
a.digitalWrite(8,0);
a.digitalWrite(9,1);
a.digitalWrite(11,0);
a.digitalWrite(12,1);
pause(0.1);
t21=a.digitalRead(3);
t22=a.digitalRead(6);
t23=a.digitalRead(7);
t24=a.digitalRead(10);
if (t21==0 && t22==0 && t23==0 && t24==0)
a.digitalWrite(13,1);
a.digitalWrite(2,0);
a.digitalWrite(4,1);
a.digitalWrite(5,0);
a.digitalWrite(8,1);
a.digitalWrite(9,0);
a.digitalWrite(11,1);
a.digitalWrite(12,0);
pause(0.1);
t31=a.digitalRead(3);
t32=a.digitalRead(6);
t33=a.digitalRead(7);
t34=a.digitalRead(10);
if (t31==0 && t32==0 && t33==0 && t34==0)
a.digitalWrite(13,1);
a.digitalWrite(2,1);
a.digitalWrite(4,1);
a.digitalWrite(5,1);
a.digitalWrite(8,1);
a.digitalWrite(9,1);
a.digitalWrite(11,1);
a.digitalWrite(12,1);
pause(0.1);
t41=a.digitalRead(3);
t42=a.digitalRead(6);
t43=a.digitalRead(7);
t44=a.digitalRead(10);
if (t41==1 && t42==1 && t43==1 && t44==1)
set(handles.text2,’String’,’IC is in working condition’);
else
set(handles.text2,’String’,’Faulty IC’);
end
else
set(handles.text2,’String’,’Faulty IC’);
end
else
set(handles.text2,’String’,’Faulty IC’);
end
else
set(handles.text2,’String’,’Faulty IC’);
end
case 5
% Your logic for case 5 here
a.pinMode(13,’output’);
a.pinMode(2,’output’);
a.pinMode(3,’input’);
a.pinMode(4,’output’);
a.pinMode(5,’output’);
a.pinMode(6,’input’);
a.pinMode(7,’input’);
a.pinMode(8,’output’);
a.pinMode(9,’output’);
a.pinMode(10,’input’);
a.pinMode(11,’output’);
a.pinMode(12,’output’);
a.digitalWrite(13,0);
a.digitalWrite(2,0);
a.digitalWrite(4,0);
a.digitalWrite(5,0);
a.digitalWrite(8,0);
a.digitalWrite(9,0);
a.digitalWrite(11,0);
a.digitalWrite(12,0);
pause(0.1);
t11=a.digitalRead(3);
t12=a.digitalRead(6);
t13=a.digitalRead(7);
t14=a.digitalRead(10);
if (t11==0 && t12==0 && t13==0 && t14==0)
a.digitalWrite(13,0);
a.digitalWrite(2,1);
a.digitalWrite(4,0);
a.digitalWrite(5,1);
a.digitalWrite(8,0);
a.digitalWrite(9,1);
a.digitalWrite(11,0);
a.digitalWrite(12,1);
pause(0.1);
t21=a.digitalRead(3);
t22=a.digitalRead(6);
t23=a.digitalRead(7);
t24=a.digitalRead(10);
if (t21==1 && t22==1 && t23==1 && t24==1)
a.digitalWrite(13,1);
a.digitalWrite(2,0);
a.digitalWrite(4,1);
a.digitalWrite(5,0);
a.digitalWrite(8,1);
a.digitalWrite(9,0);
a.digitalWrite(11,1);
a.digitalWrite(12,0);
pause(0.1);
t31=a.digitalRead(3);
t32=a.digitalRead(6);
t33=a.digitalRead(7);
t34=a.digitalRead(10);
if (t31==1 && t32==1 && t33==1 && t34==1)
a.digitalWrite(13,1);
a.digitalWrite(2,1);
a.digitalWrite(4,1);
a.digitalWrite(5,1);
a.digitalWrite(8,1);
a.digitalWrite(9,1);
a.digitalWrite(11,1);
a.digitalWrite(12,1);
pause(0.1);
t41=a.digitalRead(3);
t42=a.digitalRead(6);
t43=a.digitalRead(7);
t44=a.digitalRead(10);
if (t41==1 && t42==1 && t43==1 && t44==1)
set(handles.text2,’String’,’IC is in working condition’);
else
set(handles.text2,’String’,’Faulty IC’);
end
else
set(handles.text2,’String’,’Faulty IC’);
end
else
set(handles.text2,’String’,’Faulty IC’);
end
else
set(handles.text2,’String’,’Faulty IC’);
end
case 6
% Your logic for case 6 here
a.pinMode(13,’output’);
a.pinMode(2,’output’);
a.pinMode(3,’input’);
a.pinMode(4,’output’);
a.pinMode(5,’output’);
a.pinMode(6,’input’);
a.pinMode(7,’input’);
a.pinMode(8,’output’);
a.pinMode(9,’output’);
a.pinMode(10,’input’);
a.pinMode(11,’output’);
a.pinMode(12,’output’);
a.digitalWrite(13,0);
a.digitalWrite(2,0);
a.digitalWrite(4,0);
a.digitalWrite(5,0);
a.digitalWrite(8,0);
a.digitalWrite(9,0);
a.digitalWrite(11,0);
a.digitalWrite(12,0);
pause(0.1);
t11=a.digitalRead(3);
t12=a.digitalRead(6);
t13=a.digitalRead(7);
t14=a.digitalRead(10);
if (t11==0 && t12==0 && t13==0 && t14==0)
a.digitalWrite(13,0);
a.digitalWrite(2,1);
a.digitalWrite(4,0);
a.digitalWrite(5,1);
a.digitalWrite(8,0);
a.digitalWrite(9,1);
a.digitalWrite(11,0);
a.digitalWrite(12,1);
pause(0.1);
t21=a.digitalRead(3);
t22=a.digitalRead(6);
t23=a.digitalRead(7);
t24=a.digitalRead(10);
if (t21==1 && t22==1 && t23==1 && t24==1)
a.digitalWrite(13,1);
a.digitalWrite(2,0);
a.digitalWrite(4,1);
a.digitalWrite(5,0);
a.digitalWrite(8,1);
a.digitalWrite(9,0);
a.digitalWrite(11,1);
a.digitalWrite(12,0);
pause(0.1);
t31=a.digitalRead(3);
t32=a.digitalRead(6);
t33=a.digitalRead(7);
t34=a.digitalRead(10);
if (t31==1 && t32==1 && t33==1 && t34==1)
a.digitalWrite(13,1);
a.digitalWrite(2,1);
a.digitalWrite(4,1);
a.digitalWrite(5,1);
a.digitalWrite(8,1);
a.digitalWrite(9,1);
a.digitalWrite(11,1);
a.digitalWrite(12,1);
pause(0.1);
t41=a.digitalRead(3);
t42=a.digitalRead(6);
t43=a.digitalRead(7);
t44=a.digitalRead(10);
if (t41==0 && t42==0 && t43==0 && t44==0)
set(handles.text2,’String’,’IC is in working condition’);
else
set(handles.text2,’String’,’Faulty IC’);
end
else
set(handles.text2,’String’,’Faulty IC’);
end
else
set(handles.text2,’String’,’Faulty IC’);
end
else
set(handles.text2,’String’,’Faulty IC’);
end
otherwise
set(handles.text2, ‘String’, ‘Invalid option selected’);
end
catch
set(handles.text2, ‘String’, ‘Error testing IC’);
end
end
function pushbutton3_Callback(~, ~, handles)
if isfield(handles, ‘a’)
delete(handles.a);
set(handles.text2, ‘String’, ‘Arduino disconnected’);
end
endDot indexing is not supported for variables of this type.
Error in ic_tester>popupmenu1_CreateFcn (line 116)
set(handles.text2, ‘String’, ‘Please select an option from the dropdown’);
Error in gui_mainfcn (line 95)
feval(varargin{:});
Error in ic_tester (line 41)
gui_mainfcn(gui_State, varargin{:});
Error in matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)ic_tester(‘popupmenu1_CreateFcn’,hObject,eventdata,guidata(hObject))
im getting these errors while running my ic tester code
below is my code from ic_tester.m file
function varargout = ic_tester(varargin)
% IC_TESTER MATLAB code for ic_tester.fig
% IC_TESTER, by itself, creates a new IC_TESTER or raises the existing
% singleton*.
%
% H = IC_TESTER returns the handle to a new IC_TESTER or the handle to
% the existing singleton*.
%
% IC_TESTER(‘CALLBACK’,hObject,eventData,handles,…) calls the local
% function named CALLBACK in IC_TESTER.M with the given input arguments.
%
% IC_TESTER(‘Property’,’Value’,…) creates a new IC_TESTER or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before ic_tester_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to ic_tester_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE’s Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Last Modified by GUIDE v2.5 27-Nov-2016 17:28:30
% Begin initialization code – DO NOT EDIT
gui_Singleton = 1;
gui_State = struct(‘gui_Name’, mfilename, …
‘gui_Singleton’, gui_Singleton, …
‘gui_OpeningFcn’, @ic_tester_OpeningFcn, …
‘gui_OutputFcn’, @ic_tester_OutputFcn, …
‘gui_LayoutFcn’, [] , …
‘gui_Callback’, []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code – DO NOT EDIT
end
function ic_tester_OpeningFcn(hObject, ~, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved – to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to ic_tester (see VARARGIN)
% Choose default command line output for ic_tester
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
set(handles.text2, ‘String’, ‘Welcome! Click on "Connect" to start’);
end
function varargout = ic_tester_OutputFcn(~, ~, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved – to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.output;
end
function connectToArduino(handles)
try
handles.a = arduino(‘COM8’);
set(handles.text2, ‘String’, ‘Connected’);
catch
set(handles.text2, ‘String’, ‘Failed to connect to Arduino’);
end
end
function pushbutton1_Callback(~, ~, handles)
set(handles.text2, ‘String’, ‘Connecting…’);
connectToArduino(handles);
end
function popupmenu1_CreateFcn(hObject, ~, handles)
% hObject handle to popupmenu1 (see GCBO)
% eventdata reserved – to be defined in a future version of MATLAB
% handles empty – handles not created until after all CreateFcns called
% Hint: popupmenu controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,’BackgroundColor’), get(0,’defaultUicontrolBackgroundColor’))
set(hObject,’BackgroundColor’,’white’);
end
function pushbutton2_Callback(~, ~, handles)
if ~isfield(handles, ‘a’)
set(handles.text2, ‘String’, ‘Arduino not connected’);
return;
end
end
global n;
if isempty(n)
set(handles.text2, ‘String’, ‘Please select an option from the dropdown’);
return;
end
try
a = handles.a;
switch n
case 1
% Your logic for case 1 here
a.pinMode(2,’output’); % Changed from 13 to 2
a.pinMode(3,’output’);
a.pinMode(4,’input’); % Changed from 2 to 3
a.pinMode(5,’output’);
a.pinMode(6,’input’); % Changed from 3 to 4
a.pinMode(7,’input’);
a.pinMode(8,’output’);
a.pinMode(9,’output’);
a.pinMode(10,’input’);
a.pinMode(11,’output’);
a.pinMode(12,’output’);
a.digitalWrite(2,0);
a.digitalWrite(3,0);
a.digitalWrite(5,0);
a.digitalWrite(8,0);
a.digitalWrite(9,0);
a.digitalWrite(11,0);
a.digitalWrite(12,0);
pause(0.1);
t11=a.digitalRead(4);
t12=a.digitalRead(6);
t13=a.digitalRead(7);
t14=a.digitalRead(10);
if (t11==1 && t12==1 && t13==1 && t14==1)
a.digitalWrite(2,1);
a.digitalWrite(3,1);
a.digitalWrite(5,1);
a.digitalWrite(8,1);
a.digitalWrite(9,1);
a.digitalWrite(11,1);
a.digitalWrite(12,1);
pause(0.1);
t21=a.digitalRead(4);
t22=a.digitalRead(6);
t23=a.digitalRead(7);
t24=a.digitalRead(10);
if (t21==0 && t22==0 && t23==0 && t24==0)
set(handles.text2,’String’,’IC is in working condition’);
else
set(handles.text2,’String’,’Faulty IC’);
end
else
set(handles.text2,’String’,’Faulty IC’);
end
case 2
% Your logic for case 2 here
a.pinMode(13,’input’);
a.pinMode(2,’output’);
a.pinMode(3,’output’);
a.pinMode(4,’input’);
a.pinMode(5,’output’);
a.pinMode(6,’output’);
a.pinMode(7,’output’);
a.pinMode(8,’output’);
a.pinMode(9,’input’);
a.pinMode(10,’output’);
a.pinMode(11,’output’);
a.pinMode(12,’input’);
a.digitalWrite(2,0);
a.digitalWrite(3,0);
a.digitalWrite(5,0);
a.digitalWrite(6,0);
a.digitalWrite(7,0);
a.digitalWrite(8,0);
a.digitalWrite(10,0);
a.digitalWrite(11,0);
pause(0.1);
t11=a.digitalRead(13);
t12=a.digitalRead(4);
t13=a.digitalRead(9);
t14=a.digitalRead(12);
if (t11==1 && t12==1 && t13==1 && t14==1)
a.digitalWrite(2,0);
a.digitalWrite(3,1);
a.digitalWrite(5,0);
a.digitalWrite(6,1);
a.digitalWrite(7,0);
a.digitalWrite(8,1);
a.digitalWrite(10,0);
a.digitalWrite(11,1);
pause(0.1);
t21=a.digitalRead(13);
t22=a.digitalRead(4);
t23=a.digitalRead(9);
t24=a.digitalRead(12);
if (t21==0 && t22==0 && t23==0 && t24==0)
a.digitalWrite(2,1);
a.digitalWrite(3,0);
a.digitalWrite(5,1);
a.digitalWrite(6,0);
a.digitalWrite(7,1);
a.digitalWrite(8,0);
a.digitalWrite(10,1);
a.digitalWrite(11,0);
pause(0.1);
t31=a.digitalRead(13);
t32=a.digitalRead(4);
t33=a.digitalRead(9);
t34=a.digitalRead(12);
if (t31==0 && t32==0 && t33==0 && t34==0)
a.digitalWrite(2,1);
a.digitalWrite(3,1);
a.digitalWrite(5,1);
a.digitalWrite(6,1);
a.digitalWrite(7,1);
a.digitalWrite(8,1);
a.digitalWrite(10,1);
a.digitalWrite(11,1);
pause(0.1);
t41=a.digitalRead(13);
t42=a.digitalRead(4);
t43=a.digitalRead(9);
t44=a.digitalRead(12);
if (t41==0 && t42==0 && t43==0 && t44==0)
set(handles.text2,’String’,’IC is in working condition’);
else
set(handles.text2,’String’,’Faulty IC’);
end
else
set(handles.text2,’String’,’Faulty IC’);
end
else
set(handles.text2,’String’,’Faulty IC’);
end
else
set(handles.text2,’String’,’Faulty IC’);
end
case 3
% Your logic for case 3 here
a.pinMode(13,’output’);
a.pinMode(2,’input’);
a.pinMode(3,’output’);
a.pinMode(4,’input’);
a.pinMode(5,’output’);
a.pinMode(6,’input’);
a.pinMode(7,’input’);
a.pinMode(8,’output’);
a.pinMode(9,’input’);
a.pinMode(10,’output’);
a.pinMode(11,’input’);
a.pinMode(12,’output’);
a.digitalWrite(13,1);
a.digitalWrite(3,1);
a.digitalWrite(5,1);
a.digitalWrite(8,1);
a.digitalWrite(10,1);
a.digitalWrite(12,1);
pause(0.1);
t11=a.digitalRead(2);
t12=a.digitalRead(4);
t13=a.digitalRead(6);
t14=a.digitalRead(7);
t15=a.digitalRead(9);
t16=a.digitalRead(11);
if (t11==0 && t12==0 && t13==0 && t14==0 && t15==0 && t16==0)
a.digitalWrite(13,0);
a.digitalWrite(3,0);
a.digitalWrite(5,0);
a.digitalWrite(8,0);
a.digitalWrite(10,0);
a.digitalWrite(12,0);
pause(0.1);
t11=a.digitalRead(2);
t12=a.digitalRead(4);
t13=a.digitalRead(6);
t14=a.digitalRead(7);
t15=a.digitalRead(9);
t16=a.digitalRead(11);
if (t11==1 && t12==1 && t13==1 && t14==1 && t15==1 && t16==1)
set(handles.text2,’String’,’IC is in working condition’);
else
set(handles.text2,’String’,’Faulty IC’);
end
else
set(handles.text2,’String’,’Faulty IC’);
end
case 4
% Your logic for case 4 here
a.pinMode(13,’output’);
a.pinMode(2,’output’);
a.pinMode(3,’input’);
a.pinMode(4,’output’);
a.pinMode(5,’output’);
a.pinMode(6,’input’);
a.pinMode(7,’input’);
a.pinMode(8,’output’);
a.pinMode(9,’output’);
a.pinMode(10,’input’);
a.pinMode(11,’output’);
a.pinMode(12,’output’);
a.digitalWrite(13,0);
a.digitalWrite(2,0);
a.digitalWrite(4,0);
a.digitalWrite(5,0);
a.digitalWrite(8,0);
a.digitalWrite(9,0);
a.digitalWrite(11,0);
a.digitalWrite(12,0);
pause(0.1);
t11=a.digitalRead(3);
t12=a.digitalRead(6);
t13=a.digitalRead(7);
t14=a.digitalRead(10);
if (t11==0 && t12==0 && t13==0 && t14==0)
a.digitalWrite(13,0);
a.digitalWrite(2,1);
a.digitalWrite(4,0);
a.digitalWrite(5,1);
a.digitalWrite(8,0);
a.digitalWrite(9,1);
a.digitalWrite(11,0);
a.digitalWrite(12,1);
pause(0.1);
t21=a.digitalRead(3);
t22=a.digitalRead(6);
t23=a.digitalRead(7);
t24=a.digitalRead(10);
if (t21==0 && t22==0 && t23==0 && t24==0)
a.digitalWrite(13,1);
a.digitalWrite(2,0);
a.digitalWrite(4,1);
a.digitalWrite(5,0);
a.digitalWrite(8,1);
a.digitalWrite(9,0);
a.digitalWrite(11,1);
a.digitalWrite(12,0);
pause(0.1);
t31=a.digitalRead(3);
t32=a.digitalRead(6);
t33=a.digitalRead(7);
t34=a.digitalRead(10);
if (t31==0 && t32==0 && t33==0 && t34==0)
a.digitalWrite(13,1);
a.digitalWrite(2,1);
a.digitalWrite(4,1);
a.digitalWrite(5,1);
a.digitalWrite(8,1);
a.digitalWrite(9,1);
a.digitalWrite(11,1);
a.digitalWrite(12,1);
pause(0.1);
t41=a.digitalRead(3);
t42=a.digitalRead(6);
t43=a.digitalRead(7);
t44=a.digitalRead(10);
if (t41==1 && t42==1 && t43==1 && t44==1)
set(handles.text2,’String’,’IC is in working condition’);
else
set(handles.text2,’String’,’Faulty IC’);
end
else
set(handles.text2,’String’,’Faulty IC’);
end
else
set(handles.text2,’String’,’Faulty IC’);
end
else
set(handles.text2,’String’,’Faulty IC’);
end
case 5
% Your logic for case 5 here
a.pinMode(13,’output’);
a.pinMode(2,’output’);
a.pinMode(3,’input’);
a.pinMode(4,’output’);
a.pinMode(5,’output’);
a.pinMode(6,’input’);
a.pinMode(7,’input’);
a.pinMode(8,’output’);
a.pinMode(9,’output’);
a.pinMode(10,’input’);
a.pinMode(11,’output’);
a.pinMode(12,’output’);
a.digitalWrite(13,0);
a.digitalWrite(2,0);
a.digitalWrite(4,0);
a.digitalWrite(5,0);
a.digitalWrite(8,0);
a.digitalWrite(9,0);
a.digitalWrite(11,0);
a.digitalWrite(12,0);
pause(0.1);
t11=a.digitalRead(3);
t12=a.digitalRead(6);
t13=a.digitalRead(7);
t14=a.digitalRead(10);
if (t11==0 && t12==0 && t13==0 && t14==0)
a.digitalWrite(13,0);
a.digitalWrite(2,1);
a.digitalWrite(4,0);
a.digitalWrite(5,1);
a.digitalWrite(8,0);
a.digitalWrite(9,1);
a.digitalWrite(11,0);
a.digitalWrite(12,1);
pause(0.1);
t21=a.digitalRead(3);
t22=a.digitalRead(6);
t23=a.digitalRead(7);
t24=a.digitalRead(10);
if (t21==1 && t22==1 && t23==1 && t24==1)
a.digitalWrite(13,1);
a.digitalWrite(2,0);
a.digitalWrite(4,1);
a.digitalWrite(5,0);
a.digitalWrite(8,1);
a.digitalWrite(9,0);
a.digitalWrite(11,1);
a.digitalWrite(12,0);
pause(0.1);
t31=a.digitalRead(3);
t32=a.digitalRead(6);
t33=a.digitalRead(7);
t34=a.digitalRead(10);
if (t31==1 && t32==1 && t33==1 && t34==1)
a.digitalWrite(13,1);
a.digitalWrite(2,1);
a.digitalWrite(4,1);
a.digitalWrite(5,1);
a.digitalWrite(8,1);
a.digitalWrite(9,1);
a.digitalWrite(11,1);
a.digitalWrite(12,1);
pause(0.1);
t41=a.digitalRead(3);
t42=a.digitalRead(6);
t43=a.digitalRead(7);
t44=a.digitalRead(10);
if (t41==1 && t42==1 && t43==1 && t44==1)
set(handles.text2,’String’,’IC is in working condition’);
else
set(handles.text2,’String’,’Faulty IC’);
end
else
set(handles.text2,’String’,’Faulty IC’);
end
else
set(handles.text2,’String’,’Faulty IC’);
end
else
set(handles.text2,’String’,’Faulty IC’);
end
case 6
% Your logic for case 6 here
a.pinMode(13,’output’);
a.pinMode(2,’output’);
a.pinMode(3,’input’);
a.pinMode(4,’output’);
a.pinMode(5,’output’);
a.pinMode(6,’input’);
a.pinMode(7,’input’);
a.pinMode(8,’output’);
a.pinMode(9,’output’);
a.pinMode(10,’input’);
a.pinMode(11,’output’);
a.pinMode(12,’output’);
a.digitalWrite(13,0);
a.digitalWrite(2,0);
a.digitalWrite(4,0);
a.digitalWrite(5,0);
a.digitalWrite(8,0);
a.digitalWrite(9,0);
a.digitalWrite(11,0);
a.digitalWrite(12,0);
pause(0.1);
t11=a.digitalRead(3);
t12=a.digitalRead(6);
t13=a.digitalRead(7);
t14=a.digitalRead(10);
if (t11==0 && t12==0 && t13==0 && t14==0)
a.digitalWrite(13,0);
a.digitalWrite(2,1);
a.digitalWrite(4,0);
a.digitalWrite(5,1);
a.digitalWrite(8,0);
a.digitalWrite(9,1);
a.digitalWrite(11,0);
a.digitalWrite(12,1);
pause(0.1);
t21=a.digitalRead(3);
t22=a.digitalRead(6);
t23=a.digitalRead(7);
t24=a.digitalRead(10);
if (t21==1 && t22==1 && t23==1 && t24==1)
a.digitalWrite(13,1);
a.digitalWrite(2,0);
a.digitalWrite(4,1);
a.digitalWrite(5,0);
a.digitalWrite(8,1);
a.digitalWrite(9,0);
a.digitalWrite(11,1);
a.digitalWrite(12,0);
pause(0.1);
t31=a.digitalRead(3);
t32=a.digitalRead(6);
t33=a.digitalRead(7);
t34=a.digitalRead(10);
if (t31==1 && t32==1 && t33==1 && t34==1)
a.digitalWrite(13,1);
a.digitalWrite(2,1);
a.digitalWrite(4,1);
a.digitalWrite(5,1);
a.digitalWrite(8,1);
a.digitalWrite(9,1);
a.digitalWrite(11,1);
a.digitalWrite(12,1);
pause(0.1);
t41=a.digitalRead(3);
t42=a.digitalRead(6);
t43=a.digitalRead(7);
t44=a.digitalRead(10);
if (t41==0 && t42==0 && t43==0 && t44==0)
set(handles.text2,’String’,’IC is in working condition’);
else
set(handles.text2,’String’,’Faulty IC’);
end
else
set(handles.text2,’String’,’Faulty IC’);
end
else
set(handles.text2,’String’,’Faulty IC’);
end
else
set(handles.text2,’String’,’Faulty IC’);
end
otherwise
set(handles.text2, ‘String’, ‘Invalid option selected’);
end
catch
set(handles.text2, ‘String’, ‘Error testing IC’);
end
end
function pushbutton3_Callback(~, ~, handles)
if isfield(handles, ‘a’)
delete(handles.a);
set(handles.text2, ‘String’, ‘Arduino disconnected’);
end
end Dot indexing is not supported for variables of this type.
Error in ic_tester>popupmenu1_CreateFcn (line 116)
set(handles.text2, ‘String’, ‘Please select an option from the dropdown’);
Error in gui_mainfcn (line 95)
feval(varargin{:});
Error in ic_tester (line 41)
gui_mainfcn(gui_State, varargin{:});
Error in matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)ic_tester(‘popupmenu1_CreateFcn’,hObject,eventdata,guidata(hObject))
im getting these errors while running my ic tester code
below is my code from ic_tester.m file
function varargout = ic_tester(varargin)
% IC_TESTER MATLAB code for ic_tester.fig
% IC_TESTER, by itself, creates a new IC_TESTER or raises the existing
% singleton*.
%
% H = IC_TESTER returns the handle to a new IC_TESTER or the handle to
% the existing singleton*.
%
% IC_TESTER(‘CALLBACK’,hObject,eventData,handles,…) calls the local
% function named CALLBACK in IC_TESTER.M with the given input arguments.
%
% IC_TESTER(‘Property’,’Value’,…) creates a new IC_TESTER or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before ic_tester_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to ic_tester_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE’s Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Last Modified by GUIDE v2.5 27-Nov-2016 17:28:30
% Begin initialization code – DO NOT EDIT
gui_Singleton = 1;
gui_State = struct(‘gui_Name’, mfilename, …
‘gui_Singleton’, gui_Singleton, …
‘gui_OpeningFcn’, @ic_tester_OpeningFcn, …
‘gui_OutputFcn’, @ic_tester_OutputFcn, …
‘gui_LayoutFcn’, [] , …
‘gui_Callback’, []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code – DO NOT EDIT
end
function ic_tester_OpeningFcn(hObject, ~, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved – to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to ic_tester (see VARARGIN)
% Choose default command line output for ic_tester
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
set(handles.text2, ‘String’, ‘Welcome! Click on "Connect" to start’);
end
function varargout = ic_tester_OutputFcn(~, ~, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved – to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.output;
end
function connectToArduino(handles)
try
handles.a = arduino(‘COM8’);
set(handles.text2, ‘String’, ‘Connected’);
catch
set(handles.text2, ‘String’, ‘Failed to connect to Arduino’);
end
end
function pushbutton1_Callback(~, ~, handles)
set(handles.text2, ‘String’, ‘Connecting…’);
connectToArduino(handles);
end
function popupmenu1_CreateFcn(hObject, ~, handles)
% hObject handle to popupmenu1 (see GCBO)
% eventdata reserved – to be defined in a future version of MATLAB
% handles empty – handles not created until after all CreateFcns called
% Hint: popupmenu controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,’BackgroundColor’), get(0,’defaultUicontrolBackgroundColor’))
set(hObject,’BackgroundColor’,’white’);
end
function pushbutton2_Callback(~, ~, handles)
if ~isfield(handles, ‘a’)
set(handles.text2, ‘String’, ‘Arduino not connected’);
return;
end
end
global n;
if isempty(n)
set(handles.text2, ‘String’, ‘Please select an option from the dropdown’);
return;
end
try
a = handles.a;
switch n
case 1
% Your logic for case 1 here
a.pinMode(2,’output’); % Changed from 13 to 2
a.pinMode(3,’output’);
a.pinMode(4,’input’); % Changed from 2 to 3
a.pinMode(5,’output’);
a.pinMode(6,’input’); % Changed from 3 to 4
a.pinMode(7,’input’);
a.pinMode(8,’output’);
a.pinMode(9,’output’);
a.pinMode(10,’input’);
a.pinMode(11,’output’);
a.pinMode(12,’output’);
a.digitalWrite(2,0);
a.digitalWrite(3,0);
a.digitalWrite(5,0);
a.digitalWrite(8,0);
a.digitalWrite(9,0);
a.digitalWrite(11,0);
a.digitalWrite(12,0);
pause(0.1);
t11=a.digitalRead(4);
t12=a.digitalRead(6);
t13=a.digitalRead(7);
t14=a.digitalRead(10);
if (t11==1 && t12==1 && t13==1 && t14==1)
a.digitalWrite(2,1);
a.digitalWrite(3,1);
a.digitalWrite(5,1);
a.digitalWrite(8,1);
a.digitalWrite(9,1);
a.digitalWrite(11,1);
a.digitalWrite(12,1);
pause(0.1);
t21=a.digitalRead(4);
t22=a.digitalRead(6);
t23=a.digitalRead(7);
t24=a.digitalRead(10);
if (t21==0 && t22==0 && t23==0 && t24==0)
set(handles.text2,’String’,’IC is in working condition’);
else
set(handles.text2,’String’,’Faulty IC’);
end
else
set(handles.text2,’String’,’Faulty IC’);
end
case 2
% Your logic for case 2 here
a.pinMode(13,’input’);
a.pinMode(2,’output’);
a.pinMode(3,’output’);
a.pinMode(4,’input’);
a.pinMode(5,’output’);
a.pinMode(6,’output’);
a.pinMode(7,’output’);
a.pinMode(8,’output’);
a.pinMode(9,’input’);
a.pinMode(10,’output’);
a.pinMode(11,’output’);
a.pinMode(12,’input’);
a.digitalWrite(2,0);
a.digitalWrite(3,0);
a.digitalWrite(5,0);
a.digitalWrite(6,0);
a.digitalWrite(7,0);
a.digitalWrite(8,0);
a.digitalWrite(10,0);
a.digitalWrite(11,0);
pause(0.1);
t11=a.digitalRead(13);
t12=a.digitalRead(4);
t13=a.digitalRead(9);
t14=a.digitalRead(12);
if (t11==1 && t12==1 && t13==1 && t14==1)
a.digitalWrite(2,0);
a.digitalWrite(3,1);
a.digitalWrite(5,0);
a.digitalWrite(6,1);
a.digitalWrite(7,0);
a.digitalWrite(8,1);
a.digitalWrite(10,0);
a.digitalWrite(11,1);
pause(0.1);
t21=a.digitalRead(13);
t22=a.digitalRead(4);
t23=a.digitalRead(9);
t24=a.digitalRead(12);
if (t21==0 && t22==0 && t23==0 && t24==0)
a.digitalWrite(2,1);
a.digitalWrite(3,0);
a.digitalWrite(5,1);
a.digitalWrite(6,0);
a.digitalWrite(7,1);
a.digitalWrite(8,0);
a.digitalWrite(10,1);
a.digitalWrite(11,0);
pause(0.1);
t31=a.digitalRead(13);
t32=a.digitalRead(4);
t33=a.digitalRead(9);
t34=a.digitalRead(12);
if (t31==0 && t32==0 && t33==0 && t34==0)
a.digitalWrite(2,1);
a.digitalWrite(3,1);
a.digitalWrite(5,1);
a.digitalWrite(6,1);
a.digitalWrite(7,1);
a.digitalWrite(8,1);
a.digitalWrite(10,1);
a.digitalWrite(11,1);
pause(0.1);
t41=a.digitalRead(13);
t42=a.digitalRead(4);
t43=a.digitalRead(9);
t44=a.digitalRead(12);
if (t41==0 && t42==0 && t43==0 && t44==0)
set(handles.text2,’String’,’IC is in working condition’);
else
set(handles.text2,’String’,’Faulty IC’);
end
else
set(handles.text2,’String’,’Faulty IC’);
end
else
set(handles.text2,’String’,’Faulty IC’);
end
else
set(handles.text2,’String’,’Faulty IC’);
end
case 3
% Your logic for case 3 here
a.pinMode(13,’output’);
a.pinMode(2,’input’);
a.pinMode(3,’output’);
a.pinMode(4,’input’);
a.pinMode(5,’output’);
a.pinMode(6,’input’);
a.pinMode(7,’input’);
a.pinMode(8,’output’);
a.pinMode(9,’input’);
a.pinMode(10,’output’);
a.pinMode(11,’input’);
a.pinMode(12,’output’);
a.digitalWrite(13,1);
a.digitalWrite(3,1);
a.digitalWrite(5,1);
a.digitalWrite(8,1);
a.digitalWrite(10,1);
a.digitalWrite(12,1);
pause(0.1);
t11=a.digitalRead(2);
t12=a.digitalRead(4);
t13=a.digitalRead(6);
t14=a.digitalRead(7);
t15=a.digitalRead(9);
t16=a.digitalRead(11);
if (t11==0 && t12==0 && t13==0 && t14==0 && t15==0 && t16==0)
a.digitalWrite(13,0);
a.digitalWrite(3,0);
a.digitalWrite(5,0);
a.digitalWrite(8,0);
a.digitalWrite(10,0);
a.digitalWrite(12,0);
pause(0.1);
t11=a.digitalRead(2);
t12=a.digitalRead(4);
t13=a.digitalRead(6);
t14=a.digitalRead(7);
t15=a.digitalRead(9);
t16=a.digitalRead(11);
if (t11==1 && t12==1 && t13==1 && t14==1 && t15==1 && t16==1)
set(handles.text2,’String’,’IC is in working condition’);
else
set(handles.text2,’String’,’Faulty IC’);
end
else
set(handles.text2,’String’,’Faulty IC’);
end
case 4
% Your logic for case 4 here
a.pinMode(13,’output’);
a.pinMode(2,’output’);
a.pinMode(3,’input’);
a.pinMode(4,’output’);
a.pinMode(5,’output’);
a.pinMode(6,’input’);
a.pinMode(7,’input’);
a.pinMode(8,’output’);
a.pinMode(9,’output’);
a.pinMode(10,’input’);
a.pinMode(11,’output’);
a.pinMode(12,’output’);
a.digitalWrite(13,0);
a.digitalWrite(2,0);
a.digitalWrite(4,0);
a.digitalWrite(5,0);
a.digitalWrite(8,0);
a.digitalWrite(9,0);
a.digitalWrite(11,0);
a.digitalWrite(12,0);
pause(0.1);
t11=a.digitalRead(3);
t12=a.digitalRead(6);
t13=a.digitalRead(7);
t14=a.digitalRead(10);
if (t11==0 && t12==0 && t13==0 && t14==0)
a.digitalWrite(13,0);
a.digitalWrite(2,1);
a.digitalWrite(4,0);
a.digitalWrite(5,1);
a.digitalWrite(8,0);
a.digitalWrite(9,1);
a.digitalWrite(11,0);
a.digitalWrite(12,1);
pause(0.1);
t21=a.digitalRead(3);
t22=a.digitalRead(6);
t23=a.digitalRead(7);
t24=a.digitalRead(10);
if (t21==0 && t22==0 && t23==0 && t24==0)
a.digitalWrite(13,1);
a.digitalWrite(2,0);
a.digitalWrite(4,1);
a.digitalWrite(5,0);
a.digitalWrite(8,1);
a.digitalWrite(9,0);
a.digitalWrite(11,1);
a.digitalWrite(12,0);
pause(0.1);
t31=a.digitalRead(3);
t32=a.digitalRead(6);
t33=a.digitalRead(7);
t34=a.digitalRead(10);
if (t31==0 && t32==0 && t33==0 && t34==0)
a.digitalWrite(13,1);
a.digitalWrite(2,1);
a.digitalWrite(4,1);
a.digitalWrite(5,1);
a.digitalWrite(8,1);
a.digitalWrite(9,1);
a.digitalWrite(11,1);
a.digitalWrite(12,1);
pause(0.1);
t41=a.digitalRead(3);
t42=a.digitalRead(6);
t43=a.digitalRead(7);
t44=a.digitalRead(10);
if (t41==1 && t42==1 && t43==1 && t44==1)
set(handles.text2,’String’,’IC is in working condition’);
else
set(handles.text2,’String’,’Faulty IC’);
end
else
set(handles.text2,’String’,’Faulty IC’);
end
else
set(handles.text2,’String’,’Faulty IC’);
end
else
set(handles.text2,’String’,’Faulty IC’);
end
case 5
% Your logic for case 5 here
a.pinMode(13,’output’);
a.pinMode(2,’output’);
a.pinMode(3,’input’);
a.pinMode(4,’output’);
a.pinMode(5,’output’);
a.pinMode(6,’input’);
a.pinMode(7,’input’);
a.pinMode(8,’output’);
a.pinMode(9,’output’);
a.pinMode(10,’input’);
a.pinMode(11,’output’);
a.pinMode(12,’output’);
a.digitalWrite(13,0);
a.digitalWrite(2,0);
a.digitalWrite(4,0);
a.digitalWrite(5,0);
a.digitalWrite(8,0);
a.digitalWrite(9,0);
a.digitalWrite(11,0);
a.digitalWrite(12,0);
pause(0.1);
t11=a.digitalRead(3);
t12=a.digitalRead(6);
t13=a.digitalRead(7);
t14=a.digitalRead(10);
if (t11==0 && t12==0 && t13==0 && t14==0)
a.digitalWrite(13,0);
a.digitalWrite(2,1);
a.digitalWrite(4,0);
a.digitalWrite(5,1);
a.digitalWrite(8,0);
a.digitalWrite(9,1);
a.digitalWrite(11,0);
a.digitalWrite(12,1);
pause(0.1);
t21=a.digitalRead(3);
t22=a.digitalRead(6);
t23=a.digitalRead(7);
t24=a.digitalRead(10);
if (t21==1 && t22==1 && t23==1 && t24==1)
a.digitalWrite(13,1);
a.digitalWrite(2,0);
a.digitalWrite(4,1);
a.digitalWrite(5,0);
a.digitalWrite(8,1);
a.digitalWrite(9,0);
a.digitalWrite(11,1);
a.digitalWrite(12,0);
pause(0.1);
t31=a.digitalRead(3);
t32=a.digitalRead(6);
t33=a.digitalRead(7);
t34=a.digitalRead(10);
if (t31==1 && t32==1 && t33==1 && t34==1)
a.digitalWrite(13,1);
a.digitalWrite(2,1);
a.digitalWrite(4,1);
a.digitalWrite(5,1);
a.digitalWrite(8,1);
a.digitalWrite(9,1);
a.digitalWrite(11,1);
a.digitalWrite(12,1);
pause(0.1);
t41=a.digitalRead(3);
t42=a.digitalRead(6);
t43=a.digitalRead(7);
t44=a.digitalRead(10);
if (t41==1 && t42==1 && t43==1 && t44==1)
set(handles.text2,’String’,’IC is in working condition’);
else
set(handles.text2,’String’,’Faulty IC’);
end
else
set(handles.text2,’String’,’Faulty IC’);
end
else
set(handles.text2,’String’,’Faulty IC’);
end
else
set(handles.text2,’String’,’Faulty IC’);
end
case 6
% Your logic for case 6 here
a.pinMode(13,’output’);
a.pinMode(2,’output’);
a.pinMode(3,’input’);
a.pinMode(4,’output’);
a.pinMode(5,’output’);
a.pinMode(6,’input’);
a.pinMode(7,’input’);
a.pinMode(8,’output’);
a.pinMode(9,’output’);
a.pinMode(10,’input’);
a.pinMode(11,’output’);
a.pinMode(12,’output’);
a.digitalWrite(13,0);
a.digitalWrite(2,0);
a.digitalWrite(4,0);
a.digitalWrite(5,0);
a.digitalWrite(8,0);
a.digitalWrite(9,0);
a.digitalWrite(11,0);
a.digitalWrite(12,0);
pause(0.1);
t11=a.digitalRead(3);
t12=a.digitalRead(6);
t13=a.digitalRead(7);
t14=a.digitalRead(10);
if (t11==0 && t12==0 && t13==0 && t14==0)
a.digitalWrite(13,0);
a.digitalWrite(2,1);
a.digitalWrite(4,0);
a.digitalWrite(5,1);
a.digitalWrite(8,0);
a.digitalWrite(9,1);
a.digitalWrite(11,0);
a.digitalWrite(12,1);
pause(0.1);
t21=a.digitalRead(3);
t22=a.digitalRead(6);
t23=a.digitalRead(7);
t24=a.digitalRead(10);
if (t21==1 && t22==1 && t23==1 && t24==1)
a.digitalWrite(13,1);
a.digitalWrite(2,0);
a.digitalWrite(4,1);
a.digitalWrite(5,0);
a.digitalWrite(8,1);
a.digitalWrite(9,0);
a.digitalWrite(11,1);
a.digitalWrite(12,0);
pause(0.1);
t31=a.digitalRead(3);
t32=a.digitalRead(6);
t33=a.digitalRead(7);
t34=a.digitalRead(10);
if (t31==1 && t32==1 && t33==1 && t34==1)
a.digitalWrite(13,1);
a.digitalWrite(2,1);
a.digitalWrite(4,1);
a.digitalWrite(5,1);
a.digitalWrite(8,1);
a.digitalWrite(9,1);
a.digitalWrite(11,1);
a.digitalWrite(12,1);
pause(0.1);
t41=a.digitalRead(3);
t42=a.digitalRead(6);
t43=a.digitalRead(7);
t44=a.digitalRead(10);
if (t41==0 && t42==0 && t43==0 && t44==0)
set(handles.text2,’String’,’IC is in working condition’);
else
set(handles.text2,’String’,’Faulty IC’);
end
else
set(handles.text2,’String’,’Faulty IC’);
end
else
set(handles.text2,’String’,’Faulty IC’);
end
else
set(handles.text2,’String’,’Faulty IC’);
end
otherwise
set(handles.text2, ‘String’, ‘Invalid option selected’);
end
catch
set(handles.text2, ‘String’, ‘Error testing IC’);
end
end
function pushbutton3_Callback(~, ~, handles)
if isfield(handles, ‘a’)
delete(handles.a);
set(handles.text2, ‘String’, ‘Arduino disconnected’);
end
end matlab gui MATLAB Answers — New Questions
I faced a problem with wrokspace value that changes its name every time I run the simulation
Hi everyone!
I faced a problem with wrokspace value. I am loading several structure files(.mat), but 2 of the loaded files change their names. I already did the simulation for the similar files and similar naming. I tried to clear workspace, to use clear and clc command, tried to rerun the MATLAB, but it did not help. Could you please help me to understand why it changes the name? How can I fix that?
Note:
Previously I used files with names L5p5W_47Hz and for the new simulation I want to use L7p5W_47Hz. When I run new simulation name changes to L57p5W_47Hz.
Thank you in advance!Hi everyone!
I faced a problem with wrokspace value. I am loading several structure files(.mat), but 2 of the loaded files change their names. I already did the simulation for the similar files and similar naming. I tried to clear workspace, to use clear and clc command, tried to rerun the MATLAB, but it did not help. Could you please help me to understand why it changes the name? How can I fix that?
Note:
Previously I used files with names L5p5W_47Hz and for the new simulation I want to use L7p5W_47Hz. When I run new simulation name changes to L57p5W_47Hz.
Thank you in advance! Hi everyone!
I faced a problem with wrokspace value. I am loading several structure files(.mat), but 2 of the loaded files change their names. I already did the simulation for the similar files and similar naming. I tried to clear workspace, to use clear and clc command, tried to rerun the MATLAB, but it did not help. Could you please help me to understand why it changes the name? How can I fix that?
Note:
Previously I used files with names L5p5W_47Hz and for the new simulation I want to use L7p5W_47Hz. When I run new simulation name changes to L57p5W_47Hz.
Thank you in advance! workspace, structures MATLAB Answers — New Questions
Index exceeds the number of array elements. Index must not exceed 1.
clc
clear all
dim=2;
nset=100;
Point=sobolset(dim);
P0=net(Point,nset);
mu=1:5;
num_iterations=8;
Lu=length(mu);
for i=1:Lu
for j=1:4
chuzhi=rand(1,8);
lb=[-1,-1,0,0,0,0];
ub=[0,0,1,1,1,1];
opts = optimoptions(@fmincon,’Algorithm’,’sqp’);
[x(j,:),G1(j)]= fmincon(@(x) G(x,mu(i)),chuzhi,[],[],[],[],lb,ub,[]);
end
[optf,ord]=min(G1);
optx=x(ord,:);
Rslt1(:,i)=[optx(:,1)];
Rslt2(:,i)=[optx(:,2)];
Rslt3(:,i)=[optx(:,3)];
Rslt4(:,i)=[optx(:,4)];
Rslt5(:,i)=[optx(:,5)];
Rslt6(:,i)=[optx(:,6)];
Rslt7(:,i)=optf;
end
K1iopt(j,:)=Rslt1;
K2iopt(j,:)=Rslt2;
X1iopt(j,:)=Rslt3;
X2iopt(j,:)=Rslt4;
s1opt(j,:)=Rslt5;
s2opt(j,:)=Rslt6;
H(j,:)=Rslt7;
function G1=G(x,mu)
lambda=0:0.01:5;
k1=x(1);
k2=x(2);
zeta1=x(3);
beta2=x(4)
s1=x(5)
s2=x(6)
A=(2.*(zeta1+k1)-mu.*(lambda.^2)).*(-k2+mu.*(lambda.^2))+(4.*(lambda.^2)).*s1.*s2;
B=2.*lambda.*(-k2.*s1-2.*(zeta1+k1).*s2+lambda.^2.*(beta2.*s1+zeta1.*s2));
C=(k2-mu.*lambda.^2).*(2.*(zeta1+k1+zeta1.*k1+2.*beta2.*k1)-(mu+2.*(zeta1+(zeta1+beta2).*mu)+2.*k1).*lambda.^2+mu.*lambda.^4)+4.*lambda.^2.*(-1-k1-k2+(1+mu+mu).*lambda.^2).*s1*s2;
D=-2.*lambda.*((1+k1-(1+mu).*lambda.^2).*(-k2+mu.*lambda.^2).*s1-2.*zeta1.*s2+(-2.*(mu.*k2+k1.*(1+mu+mu)+mu.*(1+k2)).*lambda.^2-mu(1+mu).*lambda.^4).*s2);
G1=max(sqrt((A.^2+(B.^2).*s1.^2.*s2.^2)./(C.^2+(D.^2).*s1.^2.*s2.^2)));
endclc
clear all
dim=2;
nset=100;
Point=sobolset(dim);
P0=net(Point,nset);
mu=1:5;
num_iterations=8;
Lu=length(mu);
for i=1:Lu
for j=1:4
chuzhi=rand(1,8);
lb=[-1,-1,0,0,0,0];
ub=[0,0,1,1,1,1];
opts = optimoptions(@fmincon,’Algorithm’,’sqp’);
[x(j,:),G1(j)]= fmincon(@(x) G(x,mu(i)),chuzhi,[],[],[],[],lb,ub,[]);
end
[optf,ord]=min(G1);
optx=x(ord,:);
Rslt1(:,i)=[optx(:,1)];
Rslt2(:,i)=[optx(:,2)];
Rslt3(:,i)=[optx(:,3)];
Rslt4(:,i)=[optx(:,4)];
Rslt5(:,i)=[optx(:,5)];
Rslt6(:,i)=[optx(:,6)];
Rslt7(:,i)=optf;
end
K1iopt(j,:)=Rslt1;
K2iopt(j,:)=Rslt2;
X1iopt(j,:)=Rslt3;
X2iopt(j,:)=Rslt4;
s1opt(j,:)=Rslt5;
s2opt(j,:)=Rslt6;
H(j,:)=Rslt7;
function G1=G(x,mu)
lambda=0:0.01:5;
k1=x(1);
k2=x(2);
zeta1=x(3);
beta2=x(4)
s1=x(5)
s2=x(6)
A=(2.*(zeta1+k1)-mu.*(lambda.^2)).*(-k2+mu.*(lambda.^2))+(4.*(lambda.^2)).*s1.*s2;
B=2.*lambda.*(-k2.*s1-2.*(zeta1+k1).*s2+lambda.^2.*(beta2.*s1+zeta1.*s2));
C=(k2-mu.*lambda.^2).*(2.*(zeta1+k1+zeta1.*k1+2.*beta2.*k1)-(mu+2.*(zeta1+(zeta1+beta2).*mu)+2.*k1).*lambda.^2+mu.*lambda.^4)+4.*lambda.^2.*(-1-k1-k2+(1+mu+mu).*lambda.^2).*s1*s2;
D=-2.*lambda.*((1+k1-(1+mu).*lambda.^2).*(-k2+mu.*lambda.^2).*s1-2.*zeta1.*s2+(-2.*(mu.*k2+k1.*(1+mu+mu)+mu.*(1+k2)).*lambda.^2-mu(1+mu).*lambda.^4).*s2);
G1=max(sqrt((A.^2+(B.^2).*s1.^2.*s2.^2)./(C.^2+(D.^2).*s1.^2.*s2.^2)));
end clc
clear all
dim=2;
nset=100;
Point=sobolset(dim);
P0=net(Point,nset);
mu=1:5;
num_iterations=8;
Lu=length(mu);
for i=1:Lu
for j=1:4
chuzhi=rand(1,8);
lb=[-1,-1,0,0,0,0];
ub=[0,0,1,1,1,1];
opts = optimoptions(@fmincon,’Algorithm’,’sqp’);
[x(j,:),G1(j)]= fmincon(@(x) G(x,mu(i)),chuzhi,[],[],[],[],lb,ub,[]);
end
[optf,ord]=min(G1);
optx=x(ord,:);
Rslt1(:,i)=[optx(:,1)];
Rslt2(:,i)=[optx(:,2)];
Rslt3(:,i)=[optx(:,3)];
Rslt4(:,i)=[optx(:,4)];
Rslt5(:,i)=[optx(:,5)];
Rslt6(:,i)=[optx(:,6)];
Rslt7(:,i)=optf;
end
K1iopt(j,:)=Rslt1;
K2iopt(j,:)=Rslt2;
X1iopt(j,:)=Rslt3;
X2iopt(j,:)=Rslt4;
s1opt(j,:)=Rslt5;
s2opt(j,:)=Rslt6;
H(j,:)=Rslt7;
function G1=G(x,mu)
lambda=0:0.01:5;
k1=x(1);
k2=x(2);
zeta1=x(3);
beta2=x(4)
s1=x(5)
s2=x(6)
A=(2.*(zeta1+k1)-mu.*(lambda.^2)).*(-k2+mu.*(lambda.^2))+(4.*(lambda.^2)).*s1.*s2;
B=2.*lambda.*(-k2.*s1-2.*(zeta1+k1).*s2+lambda.^2.*(beta2.*s1+zeta1.*s2));
C=(k2-mu.*lambda.^2).*(2.*(zeta1+k1+zeta1.*k1+2.*beta2.*k1)-(mu+2.*(zeta1+(zeta1+beta2).*mu)+2.*k1).*lambda.^2+mu.*lambda.^4)+4.*lambda.^2.*(-1-k1-k2+(1+mu+mu).*lambda.^2).*s1*s2;
D=-2.*lambda.*((1+k1-(1+mu).*lambda.^2).*(-k2+mu.*lambda.^2).*s1-2.*zeta1.*s2+(-2.*(mu.*k2+k1.*(1+mu+mu)+mu.*(1+k2)).*lambda.^2-mu(1+mu).*lambda.^4).*s2);
G1=max(sqrt((A.^2+(B.^2).*s1.^2.*s2.^2)./(C.^2+(D.^2).*s1.^2.*s2.^2)));
end fmincon MATLAB Answers — New Questions
Unable to extract logged signal data when using simulink test and parallel compuation toolbox
MATLAB 2019b.
I;m executing maltab simulink test case with parpool of 8 workers. The test cases have "custom critieria" which verifies some of the logged signals [test.sltest_simout.get(‘logsout’).get(‘signalName’.Values.Data)].
Without PCT its working correctly.
When PCT is active, script in "custom criteria" is not able to extract data from "test" object of simulink test case.
I read online that matlab workers after execution of their job do not transfer their workspact to client matlab session. Is this the reason this issue is coming?
Any solution to overcome this problem?
Test case type: Simulink testMATLAB 2019b.
I;m executing maltab simulink test case with parpool of 8 workers. The test cases have "custom critieria" which verifies some of the logged signals [test.sltest_simout.get(‘logsout’).get(‘signalName’.Values.Data)].
Without PCT its working correctly.
When PCT is active, script in "custom criteria" is not able to extract data from "test" object of simulink test case.
I read online that matlab workers after execution of their job do not transfer their workspact to client matlab session. Is this the reason this issue is coming?
Any solution to overcome this problem?
Test case type: Simulink test MATLAB 2019b.
I;m executing maltab simulink test case with parpool of 8 workers. The test cases have "custom critieria" which verifies some of the logged signals [test.sltest_simout.get(‘logsout’).get(‘signalName’.Values.Data)].
Without PCT its working correctly.
When PCT is active, script in "custom criteria" is not able to extract data from "test" object of simulink test case.
I read online that matlab workers after execution of their job do not transfer their workspact to client matlab session. Is this the reason this issue is coming?
Any solution to overcome this problem?
Test case type: Simulink test simulink test, parallel computing toolbox MATLAB Answers — New Questions
Errors occurs while converting the code created using 5G Toolbox’s SIB1 Recovery Example to C code using Matlab Coder.
I am trying to convert the code created using the SIB1 Recovery Example of 5G toolbox into C code through Matlab coder.
However, many errors occurred and were corrected, but the two errors below have not yet been corrected.
First,
rxGrid = nrOFDMDemodulate(rxWaveform_1, nrb, scsCommon, nSlot,’SampleRate’,Fs,’CarrierFrequency’,fPhaseComp);
Error Message : In code generation, when you specify the ‘SampleRate’ name-value argument in the nrOFDMDemodulate(WAVEFORM,NRB,SCS,INITIALNSLOT,NAME,VALUE) syntax, the ‘SampleRate’ and ‘Nfft’ name-value arguments and the NRB and SCS arguments must be compile-time constants.
If the above syntax is changed as follows, incorrect operation will occur.
rxGrid = nrOFDMDemodulate(rxWaveform_1, nrb, scsCommon, nSlot);
Second,
[sib1bits,sib1CRC] = decodeDLSCH(cw,pdsch.Modulation,pdsch.NumLayers,dci.RedundancyVersion);
Error Message : When generating code, the NLAYERS input must be a constant value.
Can you resolve errors that occur in Matlab Coder?I am trying to convert the code created using the SIB1 Recovery Example of 5G toolbox into C code through Matlab coder.
However, many errors occurred and were corrected, but the two errors below have not yet been corrected.
First,
rxGrid = nrOFDMDemodulate(rxWaveform_1, nrb, scsCommon, nSlot,’SampleRate’,Fs,’CarrierFrequency’,fPhaseComp);
Error Message : In code generation, when you specify the ‘SampleRate’ name-value argument in the nrOFDMDemodulate(WAVEFORM,NRB,SCS,INITIALNSLOT,NAME,VALUE) syntax, the ‘SampleRate’ and ‘Nfft’ name-value arguments and the NRB and SCS arguments must be compile-time constants.
If the above syntax is changed as follows, incorrect operation will occur.
rxGrid = nrOFDMDemodulate(rxWaveform_1, nrb, scsCommon, nSlot);
Second,
[sib1bits,sib1CRC] = decodeDLSCH(cw,pdsch.Modulation,pdsch.NumLayers,dci.RedundancyVersion);
Error Message : When generating code, the NLAYERS input must be a constant value.
Can you resolve errors that occur in Matlab Coder? I am trying to convert the code created using the SIB1 Recovery Example of 5G toolbox into C code through Matlab coder.
However, many errors occurred and were corrected, but the two errors below have not yet been corrected.
First,
rxGrid = nrOFDMDemodulate(rxWaveform_1, nrb, scsCommon, nSlot,’SampleRate’,Fs,’CarrierFrequency’,fPhaseComp);
Error Message : In code generation, when you specify the ‘SampleRate’ name-value argument in the nrOFDMDemodulate(WAVEFORM,NRB,SCS,INITIALNSLOT,NAME,VALUE) syntax, the ‘SampleRate’ and ‘Nfft’ name-value arguments and the NRB and SCS arguments must be compile-time constants.
If the above syntax is changed as follows, incorrect operation will occur.
rxGrid = nrOFDMDemodulate(rxWaveform_1, nrb, scsCommon, nSlot);
Second,
[sib1bits,sib1CRC] = decodeDLSCH(cw,pdsch.Modulation,pdsch.NumLayers,dci.RedundancyVersion);
Error Message : When generating code, the NLAYERS input must be a constant value.
Can you resolve errors that occur in Matlab Coder? matlab coder, 5g toolbox, sib1 recovery example MATLAB Answers — New Questions
how to convert text file as it was written .m file to call functions?
I have bunch of function orders written in text file.
For example text file contains
"move(4,5)
degrade(3)
plussum(6,7)"
and those are supposed to be function name and variables.
I want matlab to read that text file as it was written im .m file to call functions with variablesI have bunch of function orders written in text file.
For example text file contains
"move(4,5)
degrade(3)
plussum(6,7)"
and those are supposed to be function name and variables.
I want matlab to read that text file as it was written im .m file to call functions with variables I have bunch of function orders written in text file.
For example text file contains
"move(4,5)
degrade(3)
plussum(6,7)"
and those are supposed to be function name and variables.
I want matlab to read that text file as it was written im .m file to call functions with variables matlab MATLAB Answers — New Questions
R2023b and Sonoma bugs
Hi
I just switched to Sonoma OSX (updated) and R2023b (updated).
Apparently there are some things not right.
For example, prior to this update, this used to work fine to set all my figures to some papersize:
>> set(groot,’DefaultFigurePaperSize’,[30 30])
>> figure
>> get(gcf,’papersize’)
ans =
8.2677 11.6929
Other properties, such as set(groot,’DefaultFigureColormap’,summer), work fine
Any help?
thanksHi
I just switched to Sonoma OSX (updated) and R2023b (updated).
Apparently there are some things not right.
For example, prior to this update, this used to work fine to set all my figures to some papersize:
>> set(groot,’DefaultFigurePaperSize’,[30 30])
>> figure
>> get(gcf,’papersize’)
ans =
8.2677 11.6929
Other properties, such as set(groot,’DefaultFigureColormap’,summer), work fine
Any help?
thanks Hi
I just switched to Sonoma OSX (updated) and R2023b (updated).
Apparently there are some things not right.
For example, prior to this update, this used to work fine to set all my figures to some papersize:
>> set(groot,’DefaultFigurePaperSize’,[30 30])
>> figure
>> get(gcf,’papersize’)
ans =
8.2677 11.6929
Other properties, such as set(groot,’DefaultFigureColormap’,summer), work fine
Any help?
thanks sonoma, mac osx, defaultfigurepapersize MATLAB Answers — New Questions
How to convert my data to fit the ‘Build Map and Localize Using Segment Matching’ example?
hello
I am following the matlab example from https://kr.mathworks.com/help/lidar/ug/build-a-map-and-localize-using-segment-matching.html#mw_rtc_BuildMapAndLocalizeUsingSegmentMatchingExample_M_27FCF3DD
I have my own ‘Velodyne-VLP-16-Data.pcap’ data with 1,537 frames collected using Velodyne Puck Lite sensor.
But since I don’t know what the example data in this example looks like, I don’t know how to apply my own data.
How can I convert my data to fit this example?
thank you.hello
I am following the matlab example from https://kr.mathworks.com/help/lidar/ug/build-a-map-and-localize-using-segment-matching.html#mw_rtc_BuildMapAndLocalizeUsingSegmentMatchingExample_M_27FCF3DD
I have my own ‘Velodyne-VLP-16-Data.pcap’ data with 1,537 frames collected using Velodyne Puck Lite sensor.
But since I don’t know what the example data in this example looks like, I don’t know how to apply my own data.
How can I convert my data to fit this example?
thank you. hello
I am following the matlab example from https://kr.mathworks.com/help/lidar/ug/build-a-map-and-localize-using-segment-matching.html#mw_rtc_BuildMapAndLocalizeUsingSegmentMatchingExample_M_27FCF3DD
I have my own ‘Velodyne-VLP-16-Data.pcap’ data with 1,537 frames collected using Velodyne Puck Lite sensor.
But since I don’t know what the example data in this example looks like, I don’t know how to apply my own data.
How can I convert my data to fit this example?
thank you. lidar, velodyne, pcap, navigation and mapping MATLAB Answers — New Questions
Error when generating HDL code for deserializer1D
Hi, I am building a system to be deployed on an RFSoC. I have used serialize blocks on the processor to stream data through the memory using an Software to AXI4-Stream block to the Programmable Logic (PL).
Instead of using the serializer/deserializer block directly, I had to go to its library and copy its system to create a subsytem in my design containing it. That was needed because I had to access the rate transition blocks and change the parameter from "Multiple of input port sample time" to "inherit" – I did that because the system wouldn’t compile with the original parameter, throwing me the following error:
"Asynchronous sample time is found at input port 0 of Rate Transition block ‘path/to/subsystem/Serializer/rateTrans’. When Rate Transition block parameter ‘Output port sample time option’ is ‘Multiple of input port sample time’, asynchronous sample time is not allowed. Consider changing ‘Output port sample time option’ to "Specify" or "Inherit"."
I could overcome this error by changing the rate transition parameter and the model worked as expected during simulation.
When the data arrives to the PL, I need to deserialize it, which worked on simulation. However, during the build phase, I got the following error, which is rather unclear how to solve, once that the serializer/deserializer are supposed to be supported by HDL Coder.
"Compilation errors when generating code for: HDL1DDs Error during MATLAB code compilation: Error Path: /usr/local/MATLAB/R2022b/toolbox/shared/system/coder/+matlab/+system/+hdlcoder/System.p Error Location: (@Row: –> 1 @Column: –> 1) System object ‘hdl.deserializer1D’ is not supported for HDL code generation."
Can you help me find out what the problem is here? Thanks in advance.Hi, I am building a system to be deployed on an RFSoC. I have used serialize blocks on the processor to stream data through the memory using an Software to AXI4-Stream block to the Programmable Logic (PL).
Instead of using the serializer/deserializer block directly, I had to go to its library and copy its system to create a subsytem in my design containing it. That was needed because I had to access the rate transition blocks and change the parameter from "Multiple of input port sample time" to "inherit" – I did that because the system wouldn’t compile with the original parameter, throwing me the following error:
"Asynchronous sample time is found at input port 0 of Rate Transition block ‘path/to/subsystem/Serializer/rateTrans’. When Rate Transition block parameter ‘Output port sample time option’ is ‘Multiple of input port sample time’, asynchronous sample time is not allowed. Consider changing ‘Output port sample time option’ to "Specify" or "Inherit"."
I could overcome this error by changing the rate transition parameter and the model worked as expected during simulation.
When the data arrives to the PL, I need to deserialize it, which worked on simulation. However, during the build phase, I got the following error, which is rather unclear how to solve, once that the serializer/deserializer are supposed to be supported by HDL Coder.
"Compilation errors when generating code for: HDL1DDs Error during MATLAB code compilation: Error Path: /usr/local/MATLAB/R2022b/toolbox/shared/system/coder/+matlab/+system/+hdlcoder/System.p Error Location: (@Row: –> 1 @Column: –> 1) System object ‘hdl.deserializer1D’ is not supported for HDL code generation."
Can you help me find out what the problem is here? Thanks in advance. Hi, I am building a system to be deployed on an RFSoC. I have used serialize blocks on the processor to stream data through the memory using an Software to AXI4-Stream block to the Programmable Logic (PL).
Instead of using the serializer/deserializer block directly, I had to go to its library and copy its system to create a subsytem in my design containing it. That was needed because I had to access the rate transition blocks and change the parameter from "Multiple of input port sample time" to "inherit" – I did that because the system wouldn’t compile with the original parameter, throwing me the following error:
"Asynchronous sample time is found at input port 0 of Rate Transition block ‘path/to/subsystem/Serializer/rateTrans’. When Rate Transition block parameter ‘Output port sample time option’ is ‘Multiple of input port sample time’, asynchronous sample time is not allowed. Consider changing ‘Output port sample time option’ to "Specify" or "Inherit"."
I could overcome this error by changing the rate transition parameter and the model worked as expected during simulation.
When the data arrives to the PL, I need to deserialize it, which worked on simulation. However, during the build phase, I got the following error, which is rather unclear how to solve, once that the serializer/deserializer are supposed to be supported by HDL Coder.
"Compilation errors when generating code for: HDL1DDs Error during MATLAB code compilation: Error Path: /usr/local/MATLAB/R2022b/toolbox/shared/system/coder/+matlab/+system/+hdlcoder/System.p Error Location: (@Row: –> 1 @Column: –> 1) System object ‘hdl.deserializer1D’ is not supported for HDL code generation."
Can you help me find out what the problem is here? Thanks in advance. soc blockset, hdl coder, soc builder, deserializer, hardware MATLAB Answers — New Questions
unable to connect the C2000 (tms320f28335) with simulink?
I am getting this error how to solve this please help me ?
C:ProgramDataMATLABSupportPackagesR2019atoolboxtargetsupportpackagestic2000registrythirdpartytoolsthirdpartytools_win64.xml not foundI am getting this error how to solve this please help me ?
C:ProgramDataMATLABSupportPackagesR2019atoolboxtargetsupportpackagestic2000registrythirdpartytoolsthirdpartytools_win64.xml not found I am getting this error how to solve this please help me ?
C:ProgramDataMATLABSupportPackagesR2019atoolboxtargetsupportpackagestic2000registrythirdpartytoolsthirdpartytools_win64.xml not found tms320f28335, dsp MATLAB Answers — New Questions
Failed to start a parallel pool in matlab2015a
Hi,
I have tried parpool and it ended as:
—————–
Error using parpool (line 103)
Failed to start a parallel pool. (For information in addition to the
causing error, validate the profile ‘local’ in the Cluster Profile
Manager.)
Caused by:
Error using parallel.internal.pool.InteractiveClient>iThrowWithCause
(line 667)
Failed to initialize the interactive session.
Error using
parallel.internal.pool.InteractiveClient>iThrowIfBadParallelJobStatus
(line 768)
The interactive communicating job failed with no message.
———-
I then tried to validate the profile ‘local’, and got these details:
———-
VALIDATION DETAILS
Profile: local
Scheduler Type: Local
Stage: Cluster connection test (parcluster)
Status: Passed
Description:Validation Passed
Command Line Output:(none)
Error Report:(none)
Debug Log:(none)
Stage: Job test (createJob)
Status: Passed
Description:Validation Passed
Command Line Output:(none)
Error Report:(none)
Debug Log:(none)
Stage: SPMD job test (createCommunicatingJob)
Status: Failed
Description:The job errored or did not reach state finished.
Command Line Output:(none)
Error Report:(none)
Debug Log:
LOG FILE OUTPUT:
Stage: Pool job test (createCommunicatingJob)
Status: Skipped
Description:Validation skipped due to previous failure.
Command Line Output:(none)
Error Report:(none)
Debug Log:(none)
Stage: Parallel pool test (parpool)
Status: Skipped
Description:Validation skipped due to previous failure.
Command Line Output:(none)
Error Report:(none)
Debug Log:(none)
——-
I have searched for answered and tried to close my computer firewall but it didn’t work. Does anyone know how to solve this problem? Thanks in advance!Hi,
I have tried parpool and it ended as:
—————–
Error using parpool (line 103)
Failed to start a parallel pool. (For information in addition to the
causing error, validate the profile ‘local’ in the Cluster Profile
Manager.)
Caused by:
Error using parallel.internal.pool.InteractiveClient>iThrowWithCause
(line 667)
Failed to initialize the interactive session.
Error using
parallel.internal.pool.InteractiveClient>iThrowIfBadParallelJobStatus
(line 768)
The interactive communicating job failed with no message.
———-
I then tried to validate the profile ‘local’, and got these details:
———-
VALIDATION DETAILS
Profile: local
Scheduler Type: Local
Stage: Cluster connection test (parcluster)
Status: Passed
Description:Validation Passed
Command Line Output:(none)
Error Report:(none)
Debug Log:(none)
Stage: Job test (createJob)
Status: Passed
Description:Validation Passed
Command Line Output:(none)
Error Report:(none)
Debug Log:(none)
Stage: SPMD job test (createCommunicatingJob)
Status: Failed
Description:The job errored or did not reach state finished.
Command Line Output:(none)
Error Report:(none)
Debug Log:
LOG FILE OUTPUT:
Stage: Pool job test (createCommunicatingJob)
Status: Skipped
Description:Validation skipped due to previous failure.
Command Line Output:(none)
Error Report:(none)
Debug Log:(none)
Stage: Parallel pool test (parpool)
Status: Skipped
Description:Validation skipped due to previous failure.
Command Line Output:(none)
Error Report:(none)
Debug Log:(none)
——-
I have searched for answered and tried to close my computer firewall but it didn’t work. Does anyone know how to solve this problem? Thanks in advance! Hi,
I have tried parpool and it ended as:
—————–
Error using parpool (line 103)
Failed to start a parallel pool. (For information in addition to the
causing error, validate the profile ‘local’ in the Cluster Profile
Manager.)
Caused by:
Error using parallel.internal.pool.InteractiveClient>iThrowWithCause
(line 667)
Failed to initialize the interactive session.
Error using
parallel.internal.pool.InteractiveClient>iThrowIfBadParallelJobStatus
(line 768)
The interactive communicating job failed with no message.
———-
I then tried to validate the profile ‘local’, and got these details:
———-
VALIDATION DETAILS
Profile: local
Scheduler Type: Local
Stage: Cluster connection test (parcluster)
Status: Passed
Description:Validation Passed
Command Line Output:(none)
Error Report:(none)
Debug Log:(none)
Stage: Job test (createJob)
Status: Passed
Description:Validation Passed
Command Line Output:(none)
Error Report:(none)
Debug Log:(none)
Stage: SPMD job test (createCommunicatingJob)
Status: Failed
Description:The job errored or did not reach state finished.
Command Line Output:(none)
Error Report:(none)
Debug Log:
LOG FILE OUTPUT:
Stage: Pool job test (createCommunicatingJob)
Status: Skipped
Description:Validation skipped due to previous failure.
Command Line Output:(none)
Error Report:(none)
Debug Log:(none)
Stage: Parallel pool test (parpool)
Status: Skipped
Description:Validation skipped due to previous failure.
Command Line Output:(none)
Error Report:(none)
Debug Log:(none)
——-
I have searched for answered and tried to close my computer firewall but it didn’t work. Does anyone know how to solve this problem? Thanks in advance! parallel computing toolbox, matlab2015a MATLAB Answers — New Questions
Why is my Vector CAN device not detected in Vehicle Network Toolbox?
I am trying to use Vector CAN VN1630A device with Vehicle Network Toolbox, but neither canChannelList command nor CAN Explorer app are able to detect my device.
How can I resolve this issue?I am trying to use Vector CAN VN1630A device with Vehicle Network Toolbox, but neither canChannelList command nor CAN Explorer app are able to detect my device.
How can I resolve this issue? I am trying to use Vector CAN VN1630A device with Vehicle Network Toolbox, but neither canChannelList command nor CAN Explorer app are able to detect my device.
How can I resolve this issue? vn1630, vector_can, not_detected, matlab_r2023b, hardware MATLAB Answers — New Questions
Solving complex linear equations with conjugate operations
Consider the following equations:
Assuming and , substitute them to equations
The real parts and imaginary parts correspondingly equate:
Regarding as unknowns, rearrange to obtain the linear system form .
The result is (using ):
My questions:
1. For complex linear equations involving conjugate operations, is it necessary to calculate them separately?
2. This is just an example. I intend to use this approach to address other similar systems of complex linear equations. In my calculations for other instances, I found the determinant of to be 1e-6, approximately zero. How should I handle this to ensure the accuracy of the equation solutions?
My MATLAB code is attached below.
clc;clear;close all;
%% Set a question
z_1_true=4+2i;%The true value of z1
z_2_true=5+3i;
ee1=z_1_true+z_2_true;%Constant term
ee2=conj(z_1_true)+2*z_2_true-z_1_true;
%% taking the real part and the imaginary part respectively, twice the number of equations
syms z_1 [2 1] real%z1
syms z_2 [2 1] real%z2
z1_com=z_1(1)+1i*z_1(2);%z1_com represents the complex form of z1
z2_com=z_2(1)+1i*z_2(2);
eqns2_com=[z1_com+z2_com-ee1;
conj(z1_com)+2*z2_com-z1_com-ee2];%Construct complex equation
eqns2=[real(eqns2_com)==0;imag(eqns2_com)==0];%Taking the real part and the imaginary part
vars=[reshape(z_1,1,2),reshape(z_2,1,2)];%The variables need to be solved
[A2,b2] = equationsToMatrix(eqns2,vars);%Extract the A and b matrices
Sol2=double(A2)double(b2);%calculation method
z1_sol2=Sol2(1)+1i*Sol2(2);z2_sol2=Sol2(3)+1i*Sol2(4);
E11=z1_sol2+z2_sol2-ee1;
E22=conj(z1_sol2)+2*z2_sol2-z1_sol2-ee2;
disp(‘Solve separately:’);
disp([‘true value of z1:’, num2str(z_1_true),’,result:’,num2str(z1_sol2),’,Error of first equation:’,num2str(E11)]);
disp([‘true value of z2:’, num2str(z_2_true),’,result:’,num2str(z2_sol2),’,Error of second equation:’,num2str(E22)]);Consider the following equations:
Assuming and , substitute them to equations
The real parts and imaginary parts correspondingly equate:
Regarding as unknowns, rearrange to obtain the linear system form .
The result is (using ):
My questions:
1. For complex linear equations involving conjugate operations, is it necessary to calculate them separately?
2. This is just an example. I intend to use this approach to address other similar systems of complex linear equations. In my calculations for other instances, I found the determinant of to be 1e-6, approximately zero. How should I handle this to ensure the accuracy of the equation solutions?
My MATLAB code is attached below.
clc;clear;close all;
%% Set a question
z_1_true=4+2i;%The true value of z1
z_2_true=5+3i;
ee1=z_1_true+z_2_true;%Constant term
ee2=conj(z_1_true)+2*z_2_true-z_1_true;
%% taking the real part and the imaginary part respectively, twice the number of equations
syms z_1 [2 1] real%z1
syms z_2 [2 1] real%z2
z1_com=z_1(1)+1i*z_1(2);%z1_com represents the complex form of z1
z2_com=z_2(1)+1i*z_2(2);
eqns2_com=[z1_com+z2_com-ee1;
conj(z1_com)+2*z2_com-z1_com-ee2];%Construct complex equation
eqns2=[real(eqns2_com)==0;imag(eqns2_com)==0];%Taking the real part and the imaginary part
vars=[reshape(z_1,1,2),reshape(z_2,1,2)];%The variables need to be solved
[A2,b2] = equationsToMatrix(eqns2,vars);%Extract the A and b matrices
Sol2=double(A2)double(b2);%calculation method
z1_sol2=Sol2(1)+1i*Sol2(2);z2_sol2=Sol2(3)+1i*Sol2(4);
E11=z1_sol2+z2_sol2-ee1;
E22=conj(z1_sol2)+2*z2_sol2-z1_sol2-ee2;
disp(‘Solve separately:’);
disp([‘true value of z1:’, num2str(z_1_true),’,result:’,num2str(z1_sol2),’,Error of first equation:’,num2str(E11)]);
disp([‘true value of z2:’, num2str(z_2_true),’,result:’,num2str(z2_sol2),’,Error of second equation:’,num2str(E22)]); Consider the following equations:
Assuming and , substitute them to equations
The real parts and imaginary parts correspondingly equate:
Regarding as unknowns, rearrange to obtain the linear system form .
The result is (using ):
My questions:
1. For complex linear equations involving conjugate operations, is it necessary to calculate them separately?
2. This is just an example. I intend to use this approach to address other similar systems of complex linear equations. In my calculations for other instances, I found the determinant of to be 1e-6, approximately zero. How should I handle this to ensure the accuracy of the equation solutions?
My MATLAB code is attached below.
clc;clear;close all;
%% Set a question
z_1_true=4+2i;%The true value of z1
z_2_true=5+3i;
ee1=z_1_true+z_2_true;%Constant term
ee2=conj(z_1_true)+2*z_2_true-z_1_true;
%% taking the real part and the imaginary part respectively, twice the number of equations
syms z_1 [2 1] real%z1
syms z_2 [2 1] real%z2
z1_com=z_1(1)+1i*z_1(2);%z1_com represents the complex form of z1
z2_com=z_2(1)+1i*z_2(2);
eqns2_com=[z1_com+z2_com-ee1;
conj(z1_com)+2*z2_com-z1_com-ee2];%Construct complex equation
eqns2=[real(eqns2_com)==0;imag(eqns2_com)==0];%Taking the real part and the imaginary part
vars=[reshape(z_1,1,2),reshape(z_2,1,2)];%The variables need to be solved
[A2,b2] = equationsToMatrix(eqns2,vars);%Extract the A and b matrices
Sol2=double(A2)double(b2);%calculation method
z1_sol2=Sol2(1)+1i*Sol2(2);z2_sol2=Sol2(3)+1i*Sol2(4);
E11=z1_sol2+z2_sol2-ee1;
E22=conj(z1_sol2)+2*z2_sol2-z1_sol2-ee2;
disp(‘Solve separately:’);
disp([‘true value of z1:’, num2str(z_1_true),’,result:’,num2str(z1_sol2),’,Error of first equation:’,num2str(E11)]);
disp([‘true value of z2:’, num2str(z_2_true),’,result:’,num2str(z2_sol2),’,Error of second equation:’,num2str(E22)]); matlab, complex analysis, linear algebra MATLAB Answers — New Questions
Error while obtaining sizes from MEX S-function ‘casadi_fun’
Hello,
I am getting this error when trying to build project in configuration desk (Dspace). When i build the model thorugh simulink, the build process does not give error, however it gives this error when building via configuration desk.Hello,
I am getting this error when trying to build project in configuration desk (Dspace). When i build the model thorugh simulink, the build process does not give error, however it gives this error when building via configuration desk. Hello,
I am getting this error when trying to build project in configuration desk (Dspace). When i build the model thorugh simulink, the build process does not give error, however it gives this error when building via configuration desk. nonlinear model predictive control, casadi MATLAB Answers — New Questions
Not able to access Python from MATLAB on Apple silicon
I referred this page https://in.mathworks.com/matlabcentral/answers/1977529-how-to-use-python-from-matlab-on-mac-with-apple-silicon?s_tid=mwa_osa_a, and executed the command "arch -x86_64 python3 -m pip myPythonPackage" from my python virtual environment, and thought that it would resolve my problem of not able to access "py.sys.path", but it didn’t help. I get the following error:
Python commands require a supported version of CPython. See Getting Started with Python.
My Python environement is given as below when printed from within MATLAB:
PythonEnvironment with properties:
Version: "3.9"
Executable: "/Users/<user-name>/venv/bin/python"
Library: "/opt/homebrew/opt/python@3.9/Frameworks/Python.framework/Versions/3.9/lib/libpython3.9.dylib"
Home: "/Users/<user-name>/venv"
Status: NotLoaded
ExecutionMode: InProcess
Note that executing "arch -x86_64 python3 -m pip myPythonPackage" resulted the following error:
arch: posix_spawnp: python3: Bad CPU type in executable
My MATLAB verison is 2021b on Apple M1 Pro
Any help will be highly appreciated.I referred this page https://in.mathworks.com/matlabcentral/answers/1977529-how-to-use-python-from-matlab-on-mac-with-apple-silicon?s_tid=mwa_osa_a, and executed the command "arch -x86_64 python3 -m pip myPythonPackage" from my python virtual environment, and thought that it would resolve my problem of not able to access "py.sys.path", but it didn’t help. I get the following error:
Python commands require a supported version of CPython. See Getting Started with Python.
My Python environement is given as below when printed from within MATLAB:
PythonEnvironment with properties:
Version: "3.9"
Executable: "/Users/<user-name>/venv/bin/python"
Library: "/opt/homebrew/opt/python@3.9/Frameworks/Python.framework/Versions/3.9/lib/libpython3.9.dylib"
Home: "/Users/<user-name>/venv"
Status: NotLoaded
ExecutionMode: InProcess
Note that executing "arch -x86_64 python3 -m pip myPythonPackage" resulted the following error:
arch: posix_spawnp: python3: Bad CPU type in executable
My MATLAB verison is 2021b on Apple M1 Pro
Any help will be highly appreciated. I referred this page https://in.mathworks.com/matlabcentral/answers/1977529-how-to-use-python-from-matlab-on-mac-with-apple-silicon?s_tid=mwa_osa_a, and executed the command "arch -x86_64 python3 -m pip myPythonPackage" from my python virtual environment, and thought that it would resolve my problem of not able to access "py.sys.path", but it didn’t help. I get the following error:
Python commands require a supported version of CPython. See Getting Started with Python.
My Python environement is given as below when printed from within MATLAB:
PythonEnvironment with properties:
Version: "3.9"
Executable: "/Users/<user-name>/venv/bin/python"
Library: "/opt/homebrew/opt/python@3.9/Frameworks/Python.framework/Versions/3.9/lib/libpython3.9.dylib"
Home: "/Users/<user-name>/venv"
Status: NotLoaded
ExecutionMode: InProcess
Note that executing "arch -x86_64 python3 -m pip myPythonPackage" resulted the following error:
arch: posix_spawnp: python3: Bad CPU type in executable
My MATLAB verison is 2021b on Apple M1 Pro
Any help will be highly appreciated. matlab 2021b python apple silicon m1 pro macbook MATLAB Answers — New Questions
How to resolve this error in simscape multibody : “Model not assembled: position violation”.
Hello team,
I am using Matlab R2021A.
I will share photos below for the working and not working model that i created in smnew :
When i am working with half symetrical model my model is running, but if i create full system model and both needs to be synced togethor it’s throwing the error – "Model not assembled: position violation" .
Half Model:
This model is working with output as shown in below images (angular travel of 100 degrees).
Initial Position: Final Position:
This is half of the total assembly, if i create full and dont link these two systems than also it runs but with different speed and travel in degrees even though i am passing same inputs to both side. But if i connect these two with a rigid geometry than the error arises.
I comment out solid block connecting two subsystems to make connection between two symetrical systems.
Not connected (Not synced) ( Working) Connected ( Not working throwing error)
Although i am very confident with frame definations thay are very correct.
Kindly help me in solving this error as this is very important for me and needs to be done in very short time frame. i will be very thankfull to team if they help me crack this.Hello team,
I am using Matlab R2021A.
I will share photos below for the working and not working model that i created in smnew :
When i am working with half symetrical model my model is running, but if i create full system model and both needs to be synced togethor it’s throwing the error – "Model not assembled: position violation" .
Half Model:
This model is working with output as shown in below images (angular travel of 100 degrees).
Initial Position: Final Position:
This is half of the total assembly, if i create full and dont link these two systems than also it runs but with different speed and travel in degrees even though i am passing same inputs to both side. But if i connect these two with a rigid geometry than the error arises.
I comment out solid block connecting two subsystems to make connection between two symetrical systems.
Not connected (Not synced) ( Working) Connected ( Not working throwing error)
Although i am very confident with frame definations thay are very correct.
Kindly help me in solving this error as this is very important for me and needs to be done in very short time frame. i will be very thankfull to team if they help me crack this. Hello team,
I am using Matlab R2021A.
I will share photos below for the working and not working model that i created in smnew :
When i am working with half symetrical model my model is running, but if i create full system model and both needs to be synced togethor it’s throwing the error – "Model not assembled: position violation" .
Half Model:
This model is working with output as shown in below images (angular travel of 100 degrees).
Initial Position: Final Position:
This is half of the total assembly, if i create full and dont link these two systems than also it runs but with different speed and travel in degrees even though i am passing same inputs to both side. But if i connect these two with a rigid geometry than the error arises.
I comment out solid block connecting two subsystems to make connection between two symetrical systems.
Not connected (Not synced) ( Working) Connected ( Not working throwing error)
Although i am very confident with frame definations thay are very correct.
Kindly help me in solving this error as this is very important for me and needs to be done in very short time frame. i will be very thankfull to team if they help me crack this. simscape multibody MATLAB Answers — New Questions