Tag Archives: matlab
Extract image from lidar Map without showing figure
Hello lads
I am pretty new in Matlab and I am studying about lidar Maps.
I have been thru the example: Build Map from 2-D Lidar Scans Using SLAM – MATLAB & Simulink – MathWorks United Kingdom.
It worked fine and the lidarMap is shown in a new figure screen.
However, I would like to get the image created from that map and display it to a App GUI Image component rather than opening a new pop-up window.
I’ve been trying to create image from axes using getimage() function but, it did not work.
Can anyone please help me with that? I know it could be a silly question for Matlab experts but, any example I went thru so far did not work.
Any help is much appreciated.
Thanks
KleberHello lads
I am pretty new in Matlab and I am studying about lidar Maps.
I have been thru the example: Build Map from 2-D Lidar Scans Using SLAM – MATLAB & Simulink – MathWorks United Kingdom.
It worked fine and the lidarMap is shown in a new figure screen.
However, I would like to get the image created from that map and display it to a App GUI Image component rather than opening a new pop-up window.
I’ve been trying to create image from axes using getimage() function but, it did not work.
Can anyone please help me with that? I know it could be a silly question for Matlab experts but, any example I went thru so far did not work.
Any help is much appreciated.
Thanks
Kleber Hello lads
I am pretty new in Matlab and I am studying about lidar Maps.
I have been thru the example: Build Map from 2-D Lidar Scans Using SLAM – MATLAB & Simulink – MathWorks United Kingdom.
It worked fine and the lidarMap is shown in a new figure screen.
However, I would like to get the image created from that map and display it to a App GUI Image component rather than opening a new pop-up window.
I’ve been trying to create image from axes using getimage() function but, it did not work.
Can anyone please help me with that? I know it could be a silly question for Matlab experts but, any example I went thru so far did not work.
Any help is much appreciated.
Thanks
Kleber lidar map slam MATLAB Answers — New Questions
twitter error “HTTP/1.1 403 Forbidden'”
Hello, I seem to have a good connection but I’m receiving a "HTTP/1.1 403 Forbidden’" error. Please see below. Thanks.
>> c
c =
twitter with properties:
Name: ‘MyName’
ScreenName: ‘MyScreenName’
MetaData: [1×1 struct]
StatusCode: OK
>> d = search(c,’#MySearch’)
d =
ResponseMessage with properties:
StatusLine: ‘HTTP/1.1 403 Forbidden’
StatusCode: Forbidden
Header: [1×10 matlab.net.http.HeaderField]
Body: [1×1 matlab.net.http.MessageBody]
Completed: 0
>> ver
—————————————————————————————————–
MATLAB Version: 24.2.0.2622594 (R2024b) Prerelease
MATLAB License Number: Prerelease
Operating System: Microsoft Windows 10 Pro Version 10.0 (Build 19045)
Java Version: Java 1.8.0_202-b08 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode
—————————————————————————————————–
MATLAB Version 24.2 (R2024b)
…
Datafeed Toolbox Version 24.2 (R2024b)
…Hello, I seem to have a good connection but I’m receiving a "HTTP/1.1 403 Forbidden’" error. Please see below. Thanks.
>> c
c =
twitter with properties:
Name: ‘MyName’
ScreenName: ‘MyScreenName’
MetaData: [1×1 struct]
StatusCode: OK
>> d = search(c,’#MySearch’)
d =
ResponseMessage with properties:
StatusLine: ‘HTTP/1.1 403 Forbidden’
StatusCode: Forbidden
Header: [1×10 matlab.net.http.HeaderField]
Body: [1×1 matlab.net.http.MessageBody]
Completed: 0
>> ver
—————————————————————————————————–
MATLAB Version: 24.2.0.2622594 (R2024b) Prerelease
MATLAB License Number: Prerelease
Operating System: Microsoft Windows 10 Pro Version 10.0 (Build 19045)
Java Version: Java 1.8.0_202-b08 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode
—————————————————————————————————–
MATLAB Version 24.2 (R2024b)
…
Datafeed Toolbox Version 24.2 (R2024b)
… Hello, I seem to have a good connection but I’m receiving a "HTTP/1.1 403 Forbidden’" error. Please see below. Thanks.
>> c
c =
twitter with properties:
Name: ‘MyName’
ScreenName: ‘MyScreenName’
MetaData: [1×1 struct]
StatusCode: OK
>> d = search(c,’#MySearch’)
d =
ResponseMessage with properties:
StatusLine: ‘HTTP/1.1 403 Forbidden’
StatusCode: Forbidden
Header: [1×10 matlab.net.http.HeaderField]
Body: [1×1 matlab.net.http.MessageBody]
Completed: 0
>> ver
—————————————————————————————————–
MATLAB Version: 24.2.0.2622594 (R2024b) Prerelease
MATLAB License Number: Prerelease
Operating System: Microsoft Windows 10 Pro Version 10.0 (Build 19045)
Java Version: Java 1.8.0_202-b08 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode
—————————————————————————————————–
MATLAB Version 24.2 (R2024b)
…
Datafeed Toolbox Version 24.2 (R2024b)
… twitter x datafeed MATLAB Answers — New Questions
a D matrix with a delay block in the synchronous machine Simulink block
Hi everyone,
I have a question about a reshaped D matrix taking as an input to the discrete state space solver of the synchronous machine block in Simulink
What could be the reason to do so?Hi everyone,
I have a question about a reshaped D matrix taking as an input to the discrete state space solver of the synchronous machine block in Simulink
What could be the reason to do so? Hi everyone,
I have a question about a reshaped D matrix taking as an input to the discrete state space solver of the synchronous machine block in Simulink
What could be the reason to do so? simpowersystems, electrical machines, synchronous machines MATLAB Answers — New Questions
opening .m file results in “index exceeds the number of array elements”
I’ve yet to use MATLAB (new user) and since installing I’ve had issues with trying to open .m files from Finder (Mac). When opening .m file I get a dialog box that says "index exceeds the number of array elements. Index must not exceed 0"I’ve yet to use MATLAB (new user) and since installing I’ve had issues with trying to open .m files from Finder (Mac). When opening .m file I get a dialog box that says "index exceeds the number of array elements. Index must not exceed 0" I’ve yet to use MATLAB (new user) and since installing I’ve had issues with trying to open .m files from Finder (Mac). When opening .m file I get a dialog box that says "index exceeds the number of array elements. Index must not exceed 0" opening files MATLAB Answers — New Questions
Long scripts in thingspeak.
I use Thingspeak scripts which run in Matlab analysis are geting quite long. is there a way to have functions in one Matlab analysis called by another Matlab analysis?
thanks in advanceI use Thingspeak scripts which run in Matlab analysis are geting quite long. is there a way to have functions in one Matlab analysis called by another Matlab analysis?
thanks in advance I use Thingspeak scripts which run in Matlab analysis are geting quite long. is there a way to have functions in one Matlab analysis called by another Matlab analysis?
thanks in advance long scripts, thingspeak analysis, matlab analysis MATLAB Answers — New Questions
Interpolate y and y using a 3D vector with similar length
Hello, I have a a matrix with 3 coordinates (each column) x, y, and z. Each column has the same length. I would like to interpolate a especific coordinate xi and yi to obtain zi using the main matriz. Besides, I would like to generate a surface plot using the codinates x,y and z. I know that z should be a matrix mxn in order to do that based on the number of elements m and n according to x and y, respectively. It is worth mentioning that x, y and z are longitude, latitude and depth respectively. I would appreciate the help.Hello, I have a a matrix with 3 coordinates (each column) x, y, and z. Each column has the same length. I would like to interpolate a especific coordinate xi and yi to obtain zi using the main matriz. Besides, I would like to generate a surface plot using the codinates x,y and z. I know that z should be a matrix mxn in order to do that based on the number of elements m and n according to x and y, respectively. It is worth mentioning that x, y and z are longitude, latitude and depth respectively. I would appreciate the help. Hello, I have a a matrix with 3 coordinates (each column) x, y, and z. Each column has the same length. I would like to interpolate a especific coordinate xi and yi to obtain zi using the main matriz. Besides, I would like to generate a surface plot using the codinates x,y and z. I know that z should be a matrix mxn in order to do that based on the number of elements m and n according to x and y, respectively. It is worth mentioning that x, y and z are longitude, latitude and depth respectively. I would appreciate the help. interpolate 3d vector using x and y MATLAB Answers — New Questions
Rand in the constructor of a class and createArray
I’m attempting to use createArray to create an array of a class. The class constructor sets a property using rand. When I use createArray, every object in the array gets the same value of that property. Is there a workaround?I’m attempting to use createArray to create an array of a class. The class constructor sets a property using rand. When I use createArray, every object in the array gets the same value of that property. Is there a workaround? I’m attempting to use createArray to create an array of a class. The class constructor sets a property using rand. When I use createArray, every object in the array gets the same value of that property. Is there a workaround? createarray, random MATLAB Answers — New Questions
inputParser not supported by MATLAB Coder
I started to get into the habit of using inputParser to manage construction options to MATLAB classes I create. It just seems like the cleanest, most future-proof way to go about doing it. Now, I just hit a very annoying brick wall. I wanted to run one of these through MATLAB Coder to make a C++ version to at least serve as a template for a bit of production code. BOOM! MATLAB Coder doesn’t like functions/classes that use inputParser. Is there anyone who’s found a good workaround?I started to get into the habit of using inputParser to manage construction options to MATLAB classes I create. It just seems like the cleanest, most future-proof way to go about doing it. Now, I just hit a very annoying brick wall. I wanted to run one of these through MATLAB Coder to make a C++ version to at least serve as a template for a bit of production code. BOOM! MATLAB Coder doesn’t like functions/classes that use inputParser. Is there anyone who’s found a good workaround? I started to get into the habit of using inputParser to manage construction options to MATLAB classes I create. It just seems like the cleanest, most future-proof way to go about doing it. Now, I just hit a very annoying brick wall. I wanted to run one of these through MATLAB Coder to make a C++ version to at least serve as a template for a bit of production code. BOOM! MATLAB Coder doesn’t like functions/classes that use inputParser. Is there anyone who’s found a good workaround? inputparser MATLAB Answers — New Questions
I am trying to find the difference in two columns on my csv file to plot them and my current code isnt working.
I have a code that intakes all of my participants per there csv file and outputs there data by the objects they have seen however I cannot code the difference between the known midpoint of the object versus what they have answered. Am I overlooking something? I did change some of the info to keep more discreet sorry. Thank you to anyone who helps!
% Select CSV file and read data
[filename, path] = uigetfile(‘*.csv’, ‘Select The CSV to View Subject Data’);
myCSV = readtable(fullfile(path, filename));
% Define the column indices for KeyPressCount and ResponseTime
Midpoint = 60;
Final_Answered_Midpoint = 76;
%Assigning condition names by category {row, column}
ConditionNames{1,1} = ‘1’;
ConditionNames{2,1} = ‘2’;
ConditionNames{3,1} = ‘3’;
ConditionNames{4,1} = ‘4’;
ConditionNames{5,1} = ‘5’;
ConditionNames{6,1} = ‘6’;
ConditionNames{7,1} = ‘7’;
ConditionNames{8,1} = ‘8’;
ConditionNames{9,1} = ‘9’;
ConditionNames{10,1} = ’10’;
ConditionNames{11,1} = ’11’;
ConditionNames{12,1} = ’12’;
NbrCond = size(ConditionNames,1);
%Difference between midpoint and final slider position that was answered
difference = myCSV{:,76} – myCSV{:,60};
%Creating a loop that through each of the Categories (ConditionNames) in column 1 of myCSV and
%reports the row indices every time each category is found
for condi = 1:NbrCond
ConditionIndex(condi).RowIndices = [];
Indices = strfind(table2array(myCSV(:,1)), ConditionNames{condi,1}); %Strfind the current (condi) condition in the array
counter = 0;
for j = 1:size(Indices,1)
if ~isempty(Indices{j,1})
counter = counter + 1;
ConditionIndex(condi).RowIndices(counter) = j;
end
end
end
%Loops over each category (ConditionNames) in CSV to find data (ex:
%KeyPressCount) and stores it in AllData
for condi = 1:NbrCond
ConditionInstances = size(ConditionIndex(condi).RowIndices,2);
counter = 0;
for Condi_instance_i = 1:ConditionInstances
CurrentRowIndex = ConditionIndex(condi).RowIndices(Condi_instance_i);
counter = counter + 1;
%AllData(condi).Category(counter,1) = final_slider_position_pix-Midpoint;
AllData(condi).Category(counter,1) = myCSV{CurrentRowIndex, difference};
end
end
% Calculating Averages, Standard Deviations, and Standard Errors and
% storing them in AllData by Category (Row)
for condi = 1:NbrCond
AllData(condi).Mean = mean(AllData(condi).Category);
AllData(condi).StdDev = std(AllData(condi).Category);
AllData(condi).StdErr = AllData(condi).StdDev / sqrt(size(AllData(condi).Category, 1));
end
CategoryAvgs = cellfun(@(x) mean(x), {AllData(:).Category});
CategoryStdDevs = cellfun(@(x) std(x), {AllData(:).Category});
CategoryStdErrs = CategoryStdDevs ./ sqrt(cellfun(@numel, {AllData(:).Category}));
%Creating variable to store all of the means and standarderrors for
%plotting purposes
Means = [AllData.Mean];
StdErrs = [AllData.StdErr];
%Creating a figure to summarize results
figure;
bar([AllData.Mean]);
hold on;
errorbar(1:NbrCond, CategoryAvgs, CategoryStdErrs, ‘.k’);
ylim([-10 25])
xlabel(‘Tools’);
ylabel(‘Difference’);
% Set x-axis labels (goes in order of AllData.Mean)
xticklabels({‘1’, ‘2’, ‘3’, ‘4’, …
‘5’, ‘6’, ‘7’, ‘8’, …
‘9’, ’10’, ’11’, ’12’});
xtickangle(45)
hold off;I have a code that intakes all of my participants per there csv file and outputs there data by the objects they have seen however I cannot code the difference between the known midpoint of the object versus what they have answered. Am I overlooking something? I did change some of the info to keep more discreet sorry. Thank you to anyone who helps!
% Select CSV file and read data
[filename, path] = uigetfile(‘*.csv’, ‘Select The CSV to View Subject Data’);
myCSV = readtable(fullfile(path, filename));
% Define the column indices for KeyPressCount and ResponseTime
Midpoint = 60;
Final_Answered_Midpoint = 76;
%Assigning condition names by category {row, column}
ConditionNames{1,1} = ‘1’;
ConditionNames{2,1} = ‘2’;
ConditionNames{3,1} = ‘3’;
ConditionNames{4,1} = ‘4’;
ConditionNames{5,1} = ‘5’;
ConditionNames{6,1} = ‘6’;
ConditionNames{7,1} = ‘7’;
ConditionNames{8,1} = ‘8’;
ConditionNames{9,1} = ‘9’;
ConditionNames{10,1} = ’10’;
ConditionNames{11,1} = ’11’;
ConditionNames{12,1} = ’12’;
NbrCond = size(ConditionNames,1);
%Difference between midpoint and final slider position that was answered
difference = myCSV{:,76} – myCSV{:,60};
%Creating a loop that through each of the Categories (ConditionNames) in column 1 of myCSV and
%reports the row indices every time each category is found
for condi = 1:NbrCond
ConditionIndex(condi).RowIndices = [];
Indices = strfind(table2array(myCSV(:,1)), ConditionNames{condi,1}); %Strfind the current (condi) condition in the array
counter = 0;
for j = 1:size(Indices,1)
if ~isempty(Indices{j,1})
counter = counter + 1;
ConditionIndex(condi).RowIndices(counter) = j;
end
end
end
%Loops over each category (ConditionNames) in CSV to find data (ex:
%KeyPressCount) and stores it in AllData
for condi = 1:NbrCond
ConditionInstances = size(ConditionIndex(condi).RowIndices,2);
counter = 0;
for Condi_instance_i = 1:ConditionInstances
CurrentRowIndex = ConditionIndex(condi).RowIndices(Condi_instance_i);
counter = counter + 1;
%AllData(condi).Category(counter,1) = final_slider_position_pix-Midpoint;
AllData(condi).Category(counter,1) = myCSV{CurrentRowIndex, difference};
end
end
% Calculating Averages, Standard Deviations, and Standard Errors and
% storing them in AllData by Category (Row)
for condi = 1:NbrCond
AllData(condi).Mean = mean(AllData(condi).Category);
AllData(condi).StdDev = std(AllData(condi).Category);
AllData(condi).StdErr = AllData(condi).StdDev / sqrt(size(AllData(condi).Category, 1));
end
CategoryAvgs = cellfun(@(x) mean(x), {AllData(:).Category});
CategoryStdDevs = cellfun(@(x) std(x), {AllData(:).Category});
CategoryStdErrs = CategoryStdDevs ./ sqrt(cellfun(@numel, {AllData(:).Category}));
%Creating variable to store all of the means and standarderrors for
%plotting purposes
Means = [AllData.Mean];
StdErrs = [AllData.StdErr];
%Creating a figure to summarize results
figure;
bar([AllData.Mean]);
hold on;
errorbar(1:NbrCond, CategoryAvgs, CategoryStdErrs, ‘.k’);
ylim([-10 25])
xlabel(‘Tools’);
ylabel(‘Difference’);
% Set x-axis labels (goes in order of AllData.Mean)
xticklabels({‘1’, ‘2’, ‘3’, ‘4’, …
‘5’, ‘6’, ‘7’, ‘8’, …
‘9’, ’10’, ’11’, ’12’});
xtickangle(45)
hold off; I have a code that intakes all of my participants per there csv file and outputs there data by the objects they have seen however I cannot code the difference between the known midpoint of the object versus what they have answered. Am I overlooking something? I did change some of the info to keep more discreet sorry. Thank you to anyone who helps!
% Select CSV file and read data
[filename, path] = uigetfile(‘*.csv’, ‘Select The CSV to View Subject Data’);
myCSV = readtable(fullfile(path, filename));
% Define the column indices for KeyPressCount and ResponseTime
Midpoint = 60;
Final_Answered_Midpoint = 76;
%Assigning condition names by category {row, column}
ConditionNames{1,1} = ‘1’;
ConditionNames{2,1} = ‘2’;
ConditionNames{3,1} = ‘3’;
ConditionNames{4,1} = ‘4’;
ConditionNames{5,1} = ‘5’;
ConditionNames{6,1} = ‘6’;
ConditionNames{7,1} = ‘7’;
ConditionNames{8,1} = ‘8’;
ConditionNames{9,1} = ‘9’;
ConditionNames{10,1} = ’10’;
ConditionNames{11,1} = ’11’;
ConditionNames{12,1} = ’12’;
NbrCond = size(ConditionNames,1);
%Difference between midpoint and final slider position that was answered
difference = myCSV{:,76} – myCSV{:,60};
%Creating a loop that through each of the Categories (ConditionNames) in column 1 of myCSV and
%reports the row indices every time each category is found
for condi = 1:NbrCond
ConditionIndex(condi).RowIndices = [];
Indices = strfind(table2array(myCSV(:,1)), ConditionNames{condi,1}); %Strfind the current (condi) condition in the array
counter = 0;
for j = 1:size(Indices,1)
if ~isempty(Indices{j,1})
counter = counter + 1;
ConditionIndex(condi).RowIndices(counter) = j;
end
end
end
%Loops over each category (ConditionNames) in CSV to find data (ex:
%KeyPressCount) and stores it in AllData
for condi = 1:NbrCond
ConditionInstances = size(ConditionIndex(condi).RowIndices,2);
counter = 0;
for Condi_instance_i = 1:ConditionInstances
CurrentRowIndex = ConditionIndex(condi).RowIndices(Condi_instance_i);
counter = counter + 1;
%AllData(condi).Category(counter,1) = final_slider_position_pix-Midpoint;
AllData(condi).Category(counter,1) = myCSV{CurrentRowIndex, difference};
end
end
% Calculating Averages, Standard Deviations, and Standard Errors and
% storing them in AllData by Category (Row)
for condi = 1:NbrCond
AllData(condi).Mean = mean(AllData(condi).Category);
AllData(condi).StdDev = std(AllData(condi).Category);
AllData(condi).StdErr = AllData(condi).StdDev / sqrt(size(AllData(condi).Category, 1));
end
CategoryAvgs = cellfun(@(x) mean(x), {AllData(:).Category});
CategoryStdDevs = cellfun(@(x) std(x), {AllData(:).Category});
CategoryStdErrs = CategoryStdDevs ./ sqrt(cellfun(@numel, {AllData(:).Category}));
%Creating variable to store all of the means and standarderrors for
%plotting purposes
Means = [AllData.Mean];
StdErrs = [AllData.StdErr];
%Creating a figure to summarize results
figure;
bar([AllData.Mean]);
hold on;
errorbar(1:NbrCond, CategoryAvgs, CategoryStdErrs, ‘.k’);
ylim([-10 25])
xlabel(‘Tools’);
ylabel(‘Difference’);
% Set x-axis labels (goes in order of AllData.Mean)
xticklabels({‘1’, ‘2’, ‘3’, ‘4’, …
‘5’, ‘6’, ‘7’, ‘8’, …
‘9’, ’10’, ’11’, ’12’});
xtickangle(45)
hold off; difference MATLAB Answers — New Questions
Help converting CAN Payload in String format to engineering unit
Hello,
I have the following valiable in Matlab which holds the CAN data from a recorder in the following format:
Hexadecimal
The output of Row 1047 Should be -1951 normally and -1.951 after factoring it by 0.001. This conversion is done using this website.This is basically a force value of a Dynamometer. How can I do this conversion in Matlab? Any known function?
The closest example I found is here, but does not actually solves my problem.
The DBC is as follows:Hello,
I have the following valiable in Matlab which holds the CAN data from a recorder in the following format:
Hexadecimal
The output of Row 1047 Should be -1951 normally and -1.951 after factoring it by 0.001. This conversion is done using this website.This is basically a force value of a Dynamometer. How can I do this conversion in Matlab? Any known function?
The closest example I found is here, but does not actually solves my problem.
The DBC is as follows: Hello,
I have the following valiable in Matlab which holds the CAN data from a recorder in the following format:
Hexadecimal
The output of Row 1047 Should be -1951 normally and -1.951 after factoring it by 0.001. This conversion is done using this website.This is basically a force value of a Dynamometer. How can I do this conversion in Matlab? Any known function?
The closest example I found is here, but does not actually solves my problem.
The DBC is as follows: can, dbc MATLAB Answers — New Questions
Index in position 1 is invalid. Array indices must be positive integers or logical values Error
Pdata=0:floor(length(pressure01)/400);
for i=0:length(pressure01)
for j=0:floor(length(pressure01)/400)
if mod(i,400)==0;
Pdata(j)=pressure01(i,1);
end
end
end
Im trying to get the code to work but it gives me an error in line 5 saying "Index in position 1 is invalid. Array indices must be
positive integers or logical values."
pressure01 is a column vector, not sure whats wrongPdata=0:floor(length(pressure01)/400);
for i=0:length(pressure01)
for j=0:floor(length(pressure01)/400)
if mod(i,400)==0;
Pdata(j)=pressure01(i,1);
end
end
end
Im trying to get the code to work but it gives me an error in line 5 saying "Index in position 1 is invalid. Array indices must be
positive integers or logical values."
pressure01 is a column vector, not sure whats wrong Pdata=0:floor(length(pressure01)/400);
for i=0:length(pressure01)
for j=0:floor(length(pressure01)/400)
if mod(i,400)==0;
Pdata(j)=pressure01(i,1);
end
end
end
Im trying to get the code to work but it gives me an error in line 5 saying "Index in position 1 is invalid. Array indices must be
positive integers or logical values."
pressure01 is a column vector, not sure whats wrong code, error MATLAB Answers — New Questions
Looking for bug in a graphics program for plotting dipole fields
Greetings,
First, I apologize for postiing in the "General" area. This is the fisrt time I am asking for help in the MATLAB community and navagting this tyupe of forum. In looking of a MATAB program to plot both electric and potential fields of a dipole I came across a Book Chapter under the Academia profile of Darvin Messi on Numerical Methods. See the following link:
https://www.academia.edu/7995677/NUMERICAL_METHODS?email_work_card=view-paper&li=0
I typed in the code and worked through a majority of bugs, a couple due to typos in the text. One had to do with adding a symbol to the plot function. I got the electric fields portion to work perfectly. However, the electric potential plots still do not work. I have tried to the best of my ability to error trap. I was able to get a couple of points to plot but nothing more. I really like this approach which does not make use of MATLAB’s mesh or gradient functions because of the application I have in working with students. On the other hand, I do not know why this portion is not working. Any help would be greatly appreciated as I would not trouble the MATLAB community without exhausting the combination/permutations of what could be wrong.
I would be great to then keep the corrected version on this community as through my searches, a program like this has been requested by students very frequently.
Best wishes,
David.
%. Program below
plotit ( [-1 1], [-1.5 0; 1.5 0], 1, 1, 0.01, 0.01, 20, 20, 5)
function plotit(charges, location, ckEField, ckEq, DLE, DLV, NLE, NLV, PTS)
figure;
hold on
% Program for plotting the electric field lines
% and equipotential lines due to coplanar point charges
% the plot is to be within the range -5<x,y<5
%
% This is the correct usage:
% function plotit(charges, location,ckEField,ckEq,DLE,DLV,NLE,NLV,PTS)
%
% where,
% charges = a vector containing the charges
% location = a matrix where each row is a charge location
% ckEField = Flag set to 1 plots the Efield lines
% ckEq = Flag set to 1 plots the Equipotential lines
% DLE or DLV = the increment along E & V lines
% NLE = No. of E-Field lines per charge
% NLV = No. of Equipotential lines per charge
% PTS => Plots every PTS point (i.e. if PTS = 5 then plot every 5th point)
% note that constant Q/4*Pie*ErR is set equal to 1.0
% Determine the E-Field Lines
% For convenience, the starting points( XS,YS) are radially distributed about charge locations
Q=charges;
XQ = location(:,1);
YQ = location(:,2);
JJ=1;
NQ = length(charges);
if (ckEField)
for K=1:NQ
for I =1:NLE
THETA = 2*pi*(I-1)/(NLE);
XS=XQ(K)+0.1*cos(THETA);
YS=YQ(K)+0.1*sin(THETA);
XE=XS;
YE=YS;
JJ=JJ+1;
if (~mod(JJ,PTS))
plot(XE, YE, ‘k.’)
end
while (1)
% Find increment and new point (X,Y)
EX=0;
EY=0;
for J=1:NQ;
R =sqrt((XE-XQ(J))^2 + (YE – YQ(J))^2 );
EX = EX +Q(J)*(XE-XQ(J))/(R^3);
EY = EY +Q(J)*(YE-YQ(J))/(R^3);
end
E = sqrt(EX^2 + EY^2);
% CHECK FOR A SINGULAR POINT
if (E <=0.00005)
break;
end
DX = DLE*EX/E;
DY = DLE*EY/E;
% FOR NEGATIVE CHARGE, NEGATE DX & DY SO THAT INCREMENT IS AWAY FROM THE CHARGE
if (Q(K) < 0)
DX = -DX;
DY = -DY;
end
XE = XE + DX;
YE = YE + DY;
% CHECK WHETHER NEW POINT IS WITHIN THE GIVEN RANGE OR TOO
% CLOSE TO ANY OF THE POINT CHARGES – TO AVOID SINGULAR POINT
if ((abs(XE) >= 5) | (abs(YE) >= 5))
break;
end
if (sum(abs(XE-XQ) < 0.05 & abs(YE-YQ) < 0.05) > 0)
break;
end
JJ=JJ+1;
if (~mod(JJ,PTS))
plot(XE,YE,’k.’)
end
end % while loop
end % I =1:NLE
end % K = 1:NQ
end % if
% NEXT, DETERMINE THE EQUIPOTENTIAL LINES FOR CONVENIENCE, THE STARTING POINTS (XS,YS) ARE
% CHOSEN LIKE THOSE FOR THE E-FIELD LINES
if(ckEq)
JJ=1;
DELTA = 0.2;
ANGLE = 45*pi/180;
for K =1:NQ
FACTOR = 0.5
for KK = 1:NLV
XS = XQ(K) + FACTOR*cos(ANGLE);
YS = YQ(K) + FACTOR*sin(ANGLE);
if ( abs(XS) >= 5 | abs(YS) >=5 )
break;
end
DIR = 1;
XV = XS;
YV = YS;
JJ=JJ+1;
if (~mod(JJ,PTS))
plot(XV,YV, ‘rs’)
end
% FIND INCREMENT AND NEW POINT (XV,YV)
N=1;
while(1)
EX = 0;
EY = 0;
for J = 1:NQ
R = sqrt((XV-XQ(J))^2 + (YV-YQ(J))^2);
EX = EX + Q(J)*(XV-XQ(J))/(R^3);
EY = EY + Q(J)*(YV-YQ(J))/(R^3);
end
E=sqrt(EX^2 + EY^2);
if (E <= 0.00005)
FACTOR = 2*FACTOR;
break;
end;
DX = -(DLV*EX)/E;
DY = (DLV*EY)/E;
XV = XV + DIR*DX;
YV = YV + DIR*DY;
% CHECK IF THE EQUIPOTENTIAL LINE LOOPS BACK TO (X,YS)
R0 = sqrt((XV – XS)^2 + (YV – YS)^2);
if (R0 < DELTA & N < 50)
FACTOR = 2*FACTOR;
break;
end
% CHECK WHETHER NEW POINT IS WITHIN THE GIVEN RANGE IF FOUND OUT OF RANGE, GO BACK TO THE STARTING POINT
% (S,YS) BUT INCREMENT IN THE OPPOSITE DIRECTION
if (abs(XV) > 5 | abs(YV) > 5)
DIR = DIR – 2;
XV = XS;
YV = YS;
end
if (abs(DIR) > 1)
FACTOR = 2*FACTOR;
break;
end
if ( sum( abs(XV-XQ) < 0.005 & abs(YV-YQ) < 0.005) > 0 )
break;
end
end
JJ=JJ+1;
if (~mod(JJ,PTS))
N=N+1;
plot(XV,YV,’rs’)
end
end % WHILE loop
end % KK
end % K
end % ifGreetings,
First, I apologize for postiing in the "General" area. This is the fisrt time I am asking for help in the MATLAB community and navagting this tyupe of forum. In looking of a MATAB program to plot both electric and potential fields of a dipole I came across a Book Chapter under the Academia profile of Darvin Messi on Numerical Methods. See the following link:
https://www.academia.edu/7995677/NUMERICAL_METHODS?email_work_card=view-paper&li=0
I typed in the code and worked through a majority of bugs, a couple due to typos in the text. One had to do with adding a symbol to the plot function. I got the electric fields portion to work perfectly. However, the electric potential plots still do not work. I have tried to the best of my ability to error trap. I was able to get a couple of points to plot but nothing more. I really like this approach which does not make use of MATLAB’s mesh or gradient functions because of the application I have in working with students. On the other hand, I do not know why this portion is not working. Any help would be greatly appreciated as I would not trouble the MATLAB community without exhausting the combination/permutations of what could be wrong.
I would be great to then keep the corrected version on this community as through my searches, a program like this has been requested by students very frequently.
Best wishes,
David.
%. Program below
plotit ( [-1 1], [-1.5 0; 1.5 0], 1, 1, 0.01, 0.01, 20, 20, 5)
function plotit(charges, location, ckEField, ckEq, DLE, DLV, NLE, NLV, PTS)
figure;
hold on
% Program for plotting the electric field lines
% and equipotential lines due to coplanar point charges
% the plot is to be within the range -5<x,y<5
%
% This is the correct usage:
% function plotit(charges, location,ckEField,ckEq,DLE,DLV,NLE,NLV,PTS)
%
% where,
% charges = a vector containing the charges
% location = a matrix where each row is a charge location
% ckEField = Flag set to 1 plots the Efield lines
% ckEq = Flag set to 1 plots the Equipotential lines
% DLE or DLV = the increment along E & V lines
% NLE = No. of E-Field lines per charge
% NLV = No. of Equipotential lines per charge
% PTS => Plots every PTS point (i.e. if PTS = 5 then plot every 5th point)
% note that constant Q/4*Pie*ErR is set equal to 1.0
% Determine the E-Field Lines
% For convenience, the starting points( XS,YS) are radially distributed about charge locations
Q=charges;
XQ = location(:,1);
YQ = location(:,2);
JJ=1;
NQ = length(charges);
if (ckEField)
for K=1:NQ
for I =1:NLE
THETA = 2*pi*(I-1)/(NLE);
XS=XQ(K)+0.1*cos(THETA);
YS=YQ(K)+0.1*sin(THETA);
XE=XS;
YE=YS;
JJ=JJ+1;
if (~mod(JJ,PTS))
plot(XE, YE, ‘k.’)
end
while (1)
% Find increment and new point (X,Y)
EX=0;
EY=0;
for J=1:NQ;
R =sqrt((XE-XQ(J))^2 + (YE – YQ(J))^2 );
EX = EX +Q(J)*(XE-XQ(J))/(R^3);
EY = EY +Q(J)*(YE-YQ(J))/(R^3);
end
E = sqrt(EX^2 + EY^2);
% CHECK FOR A SINGULAR POINT
if (E <=0.00005)
break;
end
DX = DLE*EX/E;
DY = DLE*EY/E;
% FOR NEGATIVE CHARGE, NEGATE DX & DY SO THAT INCREMENT IS AWAY FROM THE CHARGE
if (Q(K) < 0)
DX = -DX;
DY = -DY;
end
XE = XE + DX;
YE = YE + DY;
% CHECK WHETHER NEW POINT IS WITHIN THE GIVEN RANGE OR TOO
% CLOSE TO ANY OF THE POINT CHARGES – TO AVOID SINGULAR POINT
if ((abs(XE) >= 5) | (abs(YE) >= 5))
break;
end
if (sum(abs(XE-XQ) < 0.05 & abs(YE-YQ) < 0.05) > 0)
break;
end
JJ=JJ+1;
if (~mod(JJ,PTS))
plot(XE,YE,’k.’)
end
end % while loop
end % I =1:NLE
end % K = 1:NQ
end % if
% NEXT, DETERMINE THE EQUIPOTENTIAL LINES FOR CONVENIENCE, THE STARTING POINTS (XS,YS) ARE
% CHOSEN LIKE THOSE FOR THE E-FIELD LINES
if(ckEq)
JJ=1;
DELTA = 0.2;
ANGLE = 45*pi/180;
for K =1:NQ
FACTOR = 0.5
for KK = 1:NLV
XS = XQ(K) + FACTOR*cos(ANGLE);
YS = YQ(K) + FACTOR*sin(ANGLE);
if ( abs(XS) >= 5 | abs(YS) >=5 )
break;
end
DIR = 1;
XV = XS;
YV = YS;
JJ=JJ+1;
if (~mod(JJ,PTS))
plot(XV,YV, ‘rs’)
end
% FIND INCREMENT AND NEW POINT (XV,YV)
N=1;
while(1)
EX = 0;
EY = 0;
for J = 1:NQ
R = sqrt((XV-XQ(J))^2 + (YV-YQ(J))^2);
EX = EX + Q(J)*(XV-XQ(J))/(R^3);
EY = EY + Q(J)*(YV-YQ(J))/(R^3);
end
E=sqrt(EX^2 + EY^2);
if (E <= 0.00005)
FACTOR = 2*FACTOR;
break;
end;
DX = -(DLV*EX)/E;
DY = (DLV*EY)/E;
XV = XV + DIR*DX;
YV = YV + DIR*DY;
% CHECK IF THE EQUIPOTENTIAL LINE LOOPS BACK TO (X,YS)
R0 = sqrt((XV – XS)^2 + (YV – YS)^2);
if (R0 < DELTA & N < 50)
FACTOR = 2*FACTOR;
break;
end
% CHECK WHETHER NEW POINT IS WITHIN THE GIVEN RANGE IF FOUND OUT OF RANGE, GO BACK TO THE STARTING POINT
% (S,YS) BUT INCREMENT IN THE OPPOSITE DIRECTION
if (abs(XV) > 5 | abs(YV) > 5)
DIR = DIR – 2;
XV = XS;
YV = YS;
end
if (abs(DIR) > 1)
FACTOR = 2*FACTOR;
break;
end
if ( sum( abs(XV-XQ) < 0.005 & abs(YV-YQ) < 0.005) > 0 )
break;
end
end
JJ=JJ+1;
if (~mod(JJ,PTS))
N=N+1;
plot(XV,YV,’rs’)
end
end % WHILE loop
end % KK
end % K
end % if Greetings,
First, I apologize for postiing in the "General" area. This is the fisrt time I am asking for help in the MATLAB community and navagting this tyupe of forum. In looking of a MATAB program to plot both electric and potential fields of a dipole I came across a Book Chapter under the Academia profile of Darvin Messi on Numerical Methods. See the following link:
https://www.academia.edu/7995677/NUMERICAL_METHODS?email_work_card=view-paper&li=0
I typed in the code and worked through a majority of bugs, a couple due to typos in the text. One had to do with adding a symbol to the plot function. I got the electric fields portion to work perfectly. However, the electric potential plots still do not work. I have tried to the best of my ability to error trap. I was able to get a couple of points to plot but nothing more. I really like this approach which does not make use of MATLAB’s mesh or gradient functions because of the application I have in working with students. On the other hand, I do not know why this portion is not working. Any help would be greatly appreciated as I would not trouble the MATLAB community without exhausting the combination/permutations of what could be wrong.
I would be great to then keep the corrected version on this community as through my searches, a program like this has been requested by students very frequently.
Best wishes,
David.
%. Program below
plotit ( [-1 1], [-1.5 0; 1.5 0], 1, 1, 0.01, 0.01, 20, 20, 5)
function plotit(charges, location, ckEField, ckEq, DLE, DLV, NLE, NLV, PTS)
figure;
hold on
% Program for plotting the electric field lines
% and equipotential lines due to coplanar point charges
% the plot is to be within the range -5<x,y<5
%
% This is the correct usage:
% function plotit(charges, location,ckEField,ckEq,DLE,DLV,NLE,NLV,PTS)
%
% where,
% charges = a vector containing the charges
% location = a matrix where each row is a charge location
% ckEField = Flag set to 1 plots the Efield lines
% ckEq = Flag set to 1 plots the Equipotential lines
% DLE or DLV = the increment along E & V lines
% NLE = No. of E-Field lines per charge
% NLV = No. of Equipotential lines per charge
% PTS => Plots every PTS point (i.e. if PTS = 5 then plot every 5th point)
% note that constant Q/4*Pie*ErR is set equal to 1.0
% Determine the E-Field Lines
% For convenience, the starting points( XS,YS) are radially distributed about charge locations
Q=charges;
XQ = location(:,1);
YQ = location(:,2);
JJ=1;
NQ = length(charges);
if (ckEField)
for K=1:NQ
for I =1:NLE
THETA = 2*pi*(I-1)/(NLE);
XS=XQ(K)+0.1*cos(THETA);
YS=YQ(K)+0.1*sin(THETA);
XE=XS;
YE=YS;
JJ=JJ+1;
if (~mod(JJ,PTS))
plot(XE, YE, ‘k.’)
end
while (1)
% Find increment and new point (X,Y)
EX=0;
EY=0;
for J=1:NQ;
R =sqrt((XE-XQ(J))^2 + (YE – YQ(J))^2 );
EX = EX +Q(J)*(XE-XQ(J))/(R^3);
EY = EY +Q(J)*(YE-YQ(J))/(R^3);
end
E = sqrt(EX^2 + EY^2);
% CHECK FOR A SINGULAR POINT
if (E <=0.00005)
break;
end
DX = DLE*EX/E;
DY = DLE*EY/E;
% FOR NEGATIVE CHARGE, NEGATE DX & DY SO THAT INCREMENT IS AWAY FROM THE CHARGE
if (Q(K) < 0)
DX = -DX;
DY = -DY;
end
XE = XE + DX;
YE = YE + DY;
% CHECK WHETHER NEW POINT IS WITHIN THE GIVEN RANGE OR TOO
% CLOSE TO ANY OF THE POINT CHARGES – TO AVOID SINGULAR POINT
if ((abs(XE) >= 5) | (abs(YE) >= 5))
break;
end
if (sum(abs(XE-XQ) < 0.05 & abs(YE-YQ) < 0.05) > 0)
break;
end
JJ=JJ+1;
if (~mod(JJ,PTS))
plot(XE,YE,’k.’)
end
end % while loop
end % I =1:NLE
end % K = 1:NQ
end % if
% NEXT, DETERMINE THE EQUIPOTENTIAL LINES FOR CONVENIENCE, THE STARTING POINTS (XS,YS) ARE
% CHOSEN LIKE THOSE FOR THE E-FIELD LINES
if(ckEq)
JJ=1;
DELTA = 0.2;
ANGLE = 45*pi/180;
for K =1:NQ
FACTOR = 0.5
for KK = 1:NLV
XS = XQ(K) + FACTOR*cos(ANGLE);
YS = YQ(K) + FACTOR*sin(ANGLE);
if ( abs(XS) >= 5 | abs(YS) >=5 )
break;
end
DIR = 1;
XV = XS;
YV = YS;
JJ=JJ+1;
if (~mod(JJ,PTS))
plot(XV,YV, ‘rs’)
end
% FIND INCREMENT AND NEW POINT (XV,YV)
N=1;
while(1)
EX = 0;
EY = 0;
for J = 1:NQ
R = sqrt((XV-XQ(J))^2 + (YV-YQ(J))^2);
EX = EX + Q(J)*(XV-XQ(J))/(R^3);
EY = EY + Q(J)*(YV-YQ(J))/(R^3);
end
E=sqrt(EX^2 + EY^2);
if (E <= 0.00005)
FACTOR = 2*FACTOR;
break;
end;
DX = -(DLV*EX)/E;
DY = (DLV*EY)/E;
XV = XV + DIR*DX;
YV = YV + DIR*DY;
% CHECK IF THE EQUIPOTENTIAL LINE LOOPS BACK TO (X,YS)
R0 = sqrt((XV – XS)^2 + (YV – YS)^2);
if (R0 < DELTA & N < 50)
FACTOR = 2*FACTOR;
break;
end
% CHECK WHETHER NEW POINT IS WITHIN THE GIVEN RANGE IF FOUND OUT OF RANGE, GO BACK TO THE STARTING POINT
% (S,YS) BUT INCREMENT IN THE OPPOSITE DIRECTION
if (abs(XV) > 5 | abs(YV) > 5)
DIR = DIR – 2;
XV = XS;
YV = YS;
end
if (abs(DIR) > 1)
FACTOR = 2*FACTOR;
break;
end
if ( sum( abs(XV-XQ) < 0.005 & abs(YV-YQ) < 0.005) > 0 )
break;
end
end
JJ=JJ+1;
if (~mod(JJ,PTS))
N=N+1;
plot(XV,YV,’rs’)
end
end % WHILE loop
end % KK
end % K
end % if graphics and visualization pl MATLAB Answers — New Questions
Trying to download version 2021b, not available in select release version in account.
Hi, I have a student license for university and my university uses version 2021b. I have downloaded Matlab again for this semester but I have got 2021a version. These versions are not compatible when I use campus computers and try to continue finishing homework on my personal computer. In my account, on the downloads page I can select any release from 2022a to 2015b, except version 2021b, the one that I need. As you can imagine its a little frustrating. Am I missing something simple? Using Macbook Pro 2021 M1.
Thanks for any help.Hi, I have a student license for university and my university uses version 2021b. I have downloaded Matlab again for this semester but I have got 2021a version. These versions are not compatible when I use campus computers and try to continue finishing homework on my personal computer. In my account, on the downloads page I can select any release from 2022a to 2015b, except version 2021b, the one that I need. As you can imagine its a little frustrating. Am I missing something simple? Using Macbook Pro 2021 M1.
Thanks for any help. Hi, I have a student license for university and my university uses version 2021b. I have downloaded Matlab again for this semester but I have got 2021a version. These versions are not compatible when I use campus computers and try to continue finishing homework on my personal computer. In my account, on the downloads page I can select any release from 2022a to 2015b, except version 2021b, the one that I need. As you can imagine its a little frustrating. Am I missing something simple? Using Macbook Pro 2021 M1.
Thanks for any help. 2021b version download not available MATLAB Answers — New Questions
How can I avoid errors due to division by zero in Simulink?
I am using a simple model in Simulink in which I use a division on two input values using a ‘Divide’ block.
During my simulation, there might be a zero value fed to the denominator of the ‘Divide’ block. This often causes a warning, an error message, or erroneous results.
How can I avoid these problems?I am using a simple model in Simulink in which I use a division on two input values using a ‘Divide’ block.
During my simulation, there might be a zero value fed to the denominator of the ‘Divide’ block. This often causes a warning, an error message, or erroneous results.
How can I avoid these problems? I am using a simple model in Simulink in which I use a division on two input values using a ‘Divide’ block.
During my simulation, there might be a zero value fed to the denominator of the ‘Divide’ block. This often causes a warning, an error message, or erroneous results.
How can I avoid these problems? zero, division, simulink, denominator, numerator, inf MATLAB Answers — New Questions
Unable to called a function
I have an Integrators and Deriivatives function, which when I called the integrators, it would said "Unrecognized function or variable ‘rk78_mex’.". I have ran this program before but for some reason it is not working now.I have an Integrators and Deriivatives function, which when I called the integrators, it would said "Unrecognized function or variable ‘rk78_mex’.". I have ran this program before but for some reason it is not working now. I have an Integrators and Deriivatives function, which when I called the integrators, it would said "Unrecognized function or variable ‘rk78_mex’.". I have ran this program before but for some reason it is not working now. ode45, integration MATLAB Answers — New Questions
ZCU111 FMCP or generic custom port R/W
I want to do some generic custom defined GPIO port R/W access on the FMCP connector of our ZCU111 board, especially LA bus [0..31] from/to PL using SOC Blockset. There does not seem to exist some generic block or some custom port feature like in the HDL workflow advisor 1.2. So are there any solutions available ? Is the Terasic F2G board supported? How can i make some generic IO R/W working on this board?
Thank you in advanceI want to do some generic custom defined GPIO port R/W access on the FMCP connector of our ZCU111 board, especially LA bus [0..31] from/to PL using SOC Blockset. There does not seem to exist some generic block or some custom port feature like in the HDL workflow advisor 1.2. So are there any solutions available ? Is the Terasic F2G board supported? How can i make some generic IO R/W working on this board?
Thank you in advance I want to do some generic custom defined GPIO port R/W access on the FMCP connector of our ZCU111 board, especially LA bus [0..31] from/to PL using SOC Blockset. There does not seem to exist some generic block or some custom port feature like in the HDL workflow advisor 1.2. So are there any solutions available ? Is the Terasic F2G board supported? How can i make some generic IO R/W working on this board?
Thank you in advance zcu111, generic custom defined gpio port r/w MATLAB Answers — New Questions
Find the closest freq in a filterbank
I am using a filter bank to run different freq signals through. I am trying to make it more efficient (to not have to use all the filters every time) so I am trying to find a way to specify in my code to only use the 3 filters with the closest center frequency to the input. Right now I am only able to input the filter numbers I want manually (with filter_number). I am not sure how I would change this. I was trying to use the ‘find’ function but was only able to make it work using freq not filter numbers. Like this:
indf = find(CenterFreqs<signal_freq)
How can I chnage something like the above line to instead use filter number in my code below?Thank you for your time!
%Parameters
fs = 16e3;
t = 0:(1/fs):0.03;
t = t(:); % ensure column vector
numFilts = 32;
filter_number = 10;
range = [50 8000];
gammaFiltBank = gammatoneFilterBank(range,numFilts,fs); % set fs explicity
input_signal = sin(2*pi*100*t)
output_signal = gammaFiltBank(input_signal);
figure %1
stem(t,output_signal(:,filter_number));
title(sprintf(‘Output of Filter %d’,filter_number))
figure
impulse_input = 0*t;
impulse_input(1) = 1;
reset(gammaFiltBank); % IMPORTANT!
yimp = gammaFiltBank(impulse_input);
%Add together outputs of specific filters
filter_number2=12;
Add1=yimp(:,filter_number);
Add2=yimp(:,filter_number2);
Total=Add1 + Add2;
stem(t,Total)
title(sprintf(‘Impulse of %d plus %d’,filter_number,filter_number2))I am using a filter bank to run different freq signals through. I am trying to make it more efficient (to not have to use all the filters every time) so I am trying to find a way to specify in my code to only use the 3 filters with the closest center frequency to the input. Right now I am only able to input the filter numbers I want manually (with filter_number). I am not sure how I would change this. I was trying to use the ‘find’ function but was only able to make it work using freq not filter numbers. Like this:
indf = find(CenterFreqs<signal_freq)
How can I chnage something like the above line to instead use filter number in my code below?Thank you for your time!
%Parameters
fs = 16e3;
t = 0:(1/fs):0.03;
t = t(:); % ensure column vector
numFilts = 32;
filter_number = 10;
range = [50 8000];
gammaFiltBank = gammatoneFilterBank(range,numFilts,fs); % set fs explicity
input_signal = sin(2*pi*100*t)
output_signal = gammaFiltBank(input_signal);
figure %1
stem(t,output_signal(:,filter_number));
title(sprintf(‘Output of Filter %d’,filter_number))
figure
impulse_input = 0*t;
impulse_input(1) = 1;
reset(gammaFiltBank); % IMPORTANT!
yimp = gammaFiltBank(impulse_input);
%Add together outputs of specific filters
filter_number2=12;
Add1=yimp(:,filter_number);
Add2=yimp(:,filter_number2);
Total=Add1 + Add2;
stem(t,Total)
title(sprintf(‘Impulse of %d plus %d’,filter_number,filter_number2)) I am using a filter bank to run different freq signals through. I am trying to make it more efficient (to not have to use all the filters every time) so I am trying to find a way to specify in my code to only use the 3 filters with the closest center frequency to the input. Right now I am only able to input the filter numbers I want manually (with filter_number). I am not sure how I would change this. I was trying to use the ‘find’ function but was only able to make it work using freq not filter numbers. Like this:
indf = find(CenterFreqs<signal_freq)
How can I chnage something like the above line to instead use filter number in my code below?Thank you for your time!
%Parameters
fs = 16e3;
t = 0:(1/fs):0.03;
t = t(:); % ensure column vector
numFilts = 32;
filter_number = 10;
range = [50 8000];
gammaFiltBank = gammatoneFilterBank(range,numFilts,fs); % set fs explicity
input_signal = sin(2*pi*100*t)
output_signal = gammaFiltBank(input_signal);
figure %1
stem(t,output_signal(:,filter_number));
title(sprintf(‘Output of Filter %d’,filter_number))
figure
impulse_input = 0*t;
impulse_input(1) = 1;
reset(gammaFiltBank); % IMPORTANT!
yimp = gammaFiltBank(impulse_input);
%Add together outputs of specific filters
filter_number2=12;
Add1=yimp(:,filter_number);
Add2=yimp(:,filter_number2);
Total=Add1 + Add2;
stem(t,Total)
title(sprintf(‘Impulse of %d plus %d’,filter_number,filter_number2)) filter, loop MATLAB Answers — New Questions
How could I fix this file path error?
Don’t know how I can fix this filepath issue..Don’t know how I can fix this filepath issue.. Don’t know how I can fix this filepath issue.. matlab, matlab code, filepath, error MATLAB Answers — New Questions
Missed blocks between two models
Hi,
I would like to know how to find the added deleted and modified blocks between two models using external custom filter
Thanks in advance please find the attached fileHi,
I would like to know how to find the added deleted and modified blocks between two models using external custom filter
Thanks in advance please find the attached file Hi,
I would like to know how to find the added deleted and modified blocks between two models using external custom filter
Thanks in advance please find the attached file filter, comparison tool, simulink, matlab compare tool MATLAB Answers — New Questions
STM32H753ZI Toolchain Folder Name Conflict
I’m trying to generate C code from a block in my Simulink model and deploy this to an STM Nucleo board with the STM32H753ZIT6 processor. I am able to generate C code from my model but have so far been unable to deploy it to the board. I have followed the instructions at https://uk.mathworks.com/help/ecoder/stm32-setup-and-configuration.html to setup the STM32 support package but when I right click the block and select "Deploy this subsystem to hardware", I get the following error:
Error:The definition of property ‘TOOLCHAIN_FOLDER_NAME’ in class ‘stm32cube.mdkarm’ differs from its definition in the superclass ‘stm32cube.mxprojectParser’. This is caused by either conflicting access permissions or differing values of the Constant attribute.
Has anyone come across this before? I cannot find the classes the error is referring to.I’m trying to generate C code from a block in my Simulink model and deploy this to an STM Nucleo board with the STM32H753ZIT6 processor. I am able to generate C code from my model but have so far been unable to deploy it to the board. I have followed the instructions at https://uk.mathworks.com/help/ecoder/stm32-setup-and-configuration.html to setup the STM32 support package but when I right click the block and select "Deploy this subsystem to hardware", I get the following error:
Error:The definition of property ‘TOOLCHAIN_FOLDER_NAME’ in class ‘stm32cube.mdkarm’ differs from its definition in the superclass ‘stm32cube.mxprojectParser’. This is caused by either conflicting access permissions or differing values of the Constant attribute.
Has anyone come across this before? I cannot find the classes the error is referring to. I’m trying to generate C code from a block in my Simulink model and deploy this to an STM Nucleo board with the STM32H753ZIT6 processor. I am able to generate C code from my model but have so far been unable to deploy it to the board. I have followed the instructions at https://uk.mathworks.com/help/ecoder/stm32-setup-and-configuration.html to setup the STM32 support package but when I right click the block and select "Deploy this subsystem to hardware", I get the following error:
Error:The definition of property ‘TOOLCHAIN_FOLDER_NAME’ in class ‘stm32cube.mdkarm’ differs from its definition in the superclass ‘stm32cube.mxprojectParser’. This is caused by either conflicting access permissions or differing values of the Constant attribute.
Has anyone come across this before? I cannot find the classes the error is referring to. stm32, embedded coder MATLAB Answers — New Questions