Category: Matlab
Category Archives: Matlab
display ‰ symbol in xlabel with latex interpreter
Hi,
I need to display a permil (textperthousand) in my xlabel but I cannot get it to work.
I’m using the following
ylabel(‘$mathrm{^{34/32}varepsilon^{mic}_{sulfate-pyrite} (textperthousand)}$’,’FontSize’,16,’Interpreter’,’latex’)Hi,
I need to display a permil (textperthousand) in my xlabel but I cannot get it to work.
I’m using the following
ylabel(‘$mathrm{^{34/32}varepsilon^{mic}_{sulfate-pyrite} (textperthousand)}$’,’FontSize’,16,’Interpreter’,’latex’) Hi,
I need to display a permil (textperthousand) in my xlabel but I cannot get it to work.
I’m using the following
ylabel(‘$mathrm{^{34/32}varepsilon^{mic}_{sulfate-pyrite} (textperthousand)}$’,’FontSize’,16,’Interpreter’,’latex’) latex, xlabel MATLAB Answers — New Questions
“N channel mosfet” conducts when Vds is negative and body diode is not modelled
I am using "N-channel MOSFET" block from simscape and i have an observation which is not plausible.
When Vds is negative the mosfet conducts. I am using threshold based modelling, parametrization from datasheet, and body diode is not modelled. Using default values when block is inserted. Tried in matlab 2021b, 2023b
Am I missing something here or is it a bug?I am using "N-channel MOSFET" block from simscape and i have an observation which is not plausible.
When Vds is negative the mosfet conducts. I am using threshold based modelling, parametrization from datasheet, and body diode is not modelled. Using default values when block is inserted. Tried in matlab 2021b, 2023b
Am I missing something here or is it a bug? I am using "N-channel MOSFET" block from simscape and i have an observation which is not plausible.
When Vds is negative the mosfet conducts. I am using threshold based modelling, parametrization from datasheet, and body diode is not modelled. Using default values when block is inserted. Tried in matlab 2021b, 2023b
Am I missing something here or is it a bug? simulink, simscape, electrical, mosfet, nmos MATLAB Answers — New Questions
How to get a list of listeners
I am currently working on a fairly large Matlab OOP codebase, with listeners defined all over the place. Unfortunately the guy who created this codebase left the company and there is not really any documentation available.
As there are so many listeners all over the place, simply querying or changing some object property frequently has unexpected side effects, making debugging very painful. Is there a simple way to get a list of all the listeners for a given property? E.g. something to the extent of getlisteners(obj.myProperty)? This would really help in figuring out what on earth the code is actually doing…
I would have expected this to be a quite basic question but somehow can not find a simple answer anywhere.
Thanks!
GijsI am currently working on a fairly large Matlab OOP codebase, with listeners defined all over the place. Unfortunately the guy who created this codebase left the company and there is not really any documentation available.
As there are so many listeners all over the place, simply querying or changing some object property frequently has unexpected side effects, making debugging very painful. Is there a simple way to get a list of all the listeners for a given property? E.g. something to the extent of getlisteners(obj.myProperty)? This would really help in figuring out what on earth the code is actually doing…
I would have expected this to be a quite basic question but somehow can not find a simple answer anywhere.
Thanks!
Gijs I am currently working on a fairly large Matlab OOP codebase, with listeners defined all over the place. Unfortunately the guy who created this codebase left the company and there is not really any documentation available.
As there are so many listeners all over the place, simply querying or changing some object property frequently has unexpected side effects, making debugging very painful. Is there a simple way to get a list of all the listeners for a given property? E.g. something to the extent of getlisteners(obj.myProperty)? This would really help in figuring out what on earth the code is actually doing…
I would have expected this to be a quite basic question but somehow can not find a simple answer anywhere.
Thanks!
Gijs events, listeners MATLAB Answers — New Questions
How can insert a ‘bodeplot’ in an axes object of AppDesigner.
Hi,
I have an application developed in the past (Matlab 2013b) with several chained GUI´s sharing information. The application was build to aid the engineers of the control section during the tasks of tunning some control loops used at the company. Now, I am migrating the application to Matlab 2020a with AppDesigner, and I have found a problem with the calls to the Matlab function ‘bodeplot’.
"Error using DynamicSystem/bodeplot (line 113)
Functionality not supported with figures created with the uifigure function. For more information, see Graphics Support in App Designer."
In my application, the calls to the function bodeplot, always have a signature similar to this:
bodeplot(handle_axis_n, sys)
Where ‘handle_axis_n’ is the handle of the axes object where the bode diagram should be plotted, and ‘sys’ the LTI object.
And are coherent with the expected signature documented in the bodeplot manual: ‘https://es.mathworks.com/help/control/ref/bodeplot.html’
If the function bodeplot is not supported with graphic containers of App Designer, How can I insert a bode plot in an application of App Designer?
Thanks in advance.Hi,
I have an application developed in the past (Matlab 2013b) with several chained GUI´s sharing information. The application was build to aid the engineers of the control section during the tasks of tunning some control loops used at the company. Now, I am migrating the application to Matlab 2020a with AppDesigner, and I have found a problem with the calls to the Matlab function ‘bodeplot’.
"Error using DynamicSystem/bodeplot (line 113)
Functionality not supported with figures created with the uifigure function. For more information, see Graphics Support in App Designer."
In my application, the calls to the function bodeplot, always have a signature similar to this:
bodeplot(handle_axis_n, sys)
Where ‘handle_axis_n’ is the handle of the axes object where the bode diagram should be plotted, and ‘sys’ the LTI object.
And are coherent with the expected signature documented in the bodeplot manual: ‘https://es.mathworks.com/help/control/ref/bodeplot.html’
If the function bodeplot is not supported with graphic containers of App Designer, How can I insert a bode plot in an application of App Designer?
Thanks in advance. Hi,
I have an application developed in the past (Matlab 2013b) with several chained GUI´s sharing information. The application was build to aid the engineers of the control section during the tasks of tunning some control loops used at the company. Now, I am migrating the application to Matlab 2020a with AppDesigner, and I have found a problem with the calls to the Matlab function ‘bodeplot’.
"Error using DynamicSystem/bodeplot (line 113)
Functionality not supported with figures created with the uifigure function. For more information, see Graphics Support in App Designer."
In my application, the calls to the function bodeplot, always have a signature similar to this:
bodeplot(handle_axis_n, sys)
Where ‘handle_axis_n’ is the handle of the axes object where the bode diagram should be plotted, and ‘sys’ the LTI object.
And are coherent with the expected signature documented in the bodeplot manual: ‘https://es.mathworks.com/help/control/ref/bodeplot.html’
If the function bodeplot is not supported with graphic containers of App Designer, How can I insert a bode plot in an application of App Designer?
Thanks in advance. app designer, bodeplot MATLAB Answers — New Questions
how to analyze downlink 5G waveform for mixed numerology?
downlink 5G waveform for mixed numerology is given in the toolbox examples.
How to analyse that for BER and internumerlogoy interference?
How to deal generated resource grid containing PSS, SSS, PBCH, DM-RS?downlink 5G waveform for mixed numerology is given in the toolbox examples.
How to analyse that for BER and internumerlogoy interference?
How to deal generated resource grid containing PSS, SSS, PBCH, DM-RS? downlink 5G waveform for mixed numerology is given in the toolbox examples.
How to analyse that for BER and internumerlogoy interference?
How to deal generated resource grid containing PSS, SSS, PBCH, DM-RS? ini analysis MATLAB Answers — New Questions
Dependency management & package manager like pip in ML
Hi all,
Matlab is officially still lacking a proper package manager like npm or pip. I do not understand how people structure projects with dependencies. I understand, there are
ML projects
ML toolboxes
several mpm versions
Toolboxes have a version number attached, projects have not. Both can be shared as a package. Projects can reference other projects, but that 1. requires the same folder structure on every developer PC and 2. requires that the correct version is checked out from the VCS (which is GIT in our case). There’s no way to define "project abc@v1.2.0" as a dependency. Just folders/prj files.
How do you do complex app developments? Like a frontent GUI app that needs several self-created toolboxes and projects? The only way is to use GIT (submodules in worst case) to do dependency managment, and that’s definitely a red flag.
Then, there’s Matlab’s mpm matlab-dockerfile/MPM.md at main · mathworks-ref-arch/matlab-dockerfile (github.com) but that’s meant to be used to install different product versions and addons, and there’s a third party mpm mobeets/mpm: Simple Matlab package management inspired by pip (github.com) which seems to be interesting, but there’s no direct support from Mathworks.
Then, it seems like there’s another mpm built-in in ML 2022b that mentions a Matlab -packages flag which is very interesting:
mpm
There’s no information about that. Starting ML with -packages reveals more:
Which seems to support different versions. But there’s no documentation anywhere, and it’s a built-in function © 2022.
What does that mean? Will there be a Mathworks’ supported package manager? What exactly is a package by the way in ML? So far, packages were a synonym to namespaces, using the +package folders. How does that work together with ML projects?
I’m in the process of re-structuring code due to a migration from Bitbucket to Gitlab and I’m at a point where a proper dependency management must take place, and that must work in CI/CD, too.
Would be very happy to hear your thoughts.
Thanks,
JanHi all,
Matlab is officially still lacking a proper package manager like npm or pip. I do not understand how people structure projects with dependencies. I understand, there are
ML projects
ML toolboxes
several mpm versions
Toolboxes have a version number attached, projects have not. Both can be shared as a package. Projects can reference other projects, but that 1. requires the same folder structure on every developer PC and 2. requires that the correct version is checked out from the VCS (which is GIT in our case). There’s no way to define "project abc@v1.2.0" as a dependency. Just folders/prj files.
How do you do complex app developments? Like a frontent GUI app that needs several self-created toolboxes and projects? The only way is to use GIT (submodules in worst case) to do dependency managment, and that’s definitely a red flag.
Then, there’s Matlab’s mpm matlab-dockerfile/MPM.md at main · mathworks-ref-arch/matlab-dockerfile (github.com) but that’s meant to be used to install different product versions and addons, and there’s a third party mpm mobeets/mpm: Simple Matlab package management inspired by pip (github.com) which seems to be interesting, but there’s no direct support from Mathworks.
Then, it seems like there’s another mpm built-in in ML 2022b that mentions a Matlab -packages flag which is very interesting:
mpm
There’s no information about that. Starting ML with -packages reveals more:
Which seems to support different versions. But there’s no documentation anywhere, and it’s a built-in function © 2022.
What does that mean? Will there be a Mathworks’ supported package manager? What exactly is a package by the way in ML? So far, packages were a synonym to namespaces, using the +package folders. How does that work together with ML projects?
I’m in the process of re-structuring code due to a migration from Bitbucket to Gitlab and I’m at a point where a proper dependency management must take place, and that must work in CI/CD, too.
Would be very happy to hear your thoughts.
Thanks,
Jan Hi all,
Matlab is officially still lacking a proper package manager like npm or pip. I do not understand how people structure projects with dependencies. I understand, there are
ML projects
ML toolboxes
several mpm versions
Toolboxes have a version number attached, projects have not. Both can be shared as a package. Projects can reference other projects, but that 1. requires the same folder structure on every developer PC and 2. requires that the correct version is checked out from the VCS (which is GIT in our case). There’s no way to define "project abc@v1.2.0" as a dependency. Just folders/prj files.
How do you do complex app developments? Like a frontent GUI app that needs several self-created toolboxes and projects? The only way is to use GIT (submodules in worst case) to do dependency managment, and that’s definitely a red flag.
Then, there’s Matlab’s mpm matlab-dockerfile/MPM.md at main · mathworks-ref-arch/matlab-dockerfile (github.com) but that’s meant to be used to install different product versions and addons, and there’s a third party mpm mobeets/mpm: Simple Matlab package management inspired by pip (github.com) which seems to be interesting, but there’s no direct support from Mathworks.
Then, it seems like there’s another mpm built-in in ML 2022b that mentions a Matlab -packages flag which is very interesting:
mpm
There’s no information about that. Starting ML with -packages reveals more:
Which seems to support different versions. But there’s no documentation anywhere, and it’s a built-in function © 2022.
What does that mean? Will there be a Mathworks’ supported package manager? What exactly is a package by the way in ML? So far, packages were a synonym to namespaces, using the +package folders. How does that work together with ML projects?
I’m in the process of re-structuring code due to a migration from Bitbucket to Gitlab and I’m at a point where a proper dependency management must take place, and that must work in CI/CD, too.
Would be very happy to hear your thoughts.
Thanks,
Jan mpm, dependency management, matlab projects, pip MATLAB Answers — New Questions
Change marker colour of pzplot
Hello everyone
I’m trying to change the marker color in the pzplot graph. I’m using version 2024b.
Apparently, in this version, a new object(?) called "PZPlot Properties" was introduced, which is great.
Using this new object, I can easily change the size and line thickness of all markers. But I can also only change the colour of all markers. I’d like to change the colours of the markers for the poles and zeros separately.
I tried using the "findobj" method and found, that the PZPlot apparently consists of two Scatter-Plots called "PZPoleScatter" and "PZZeroScatter", and I tried changing the color of the markers in those Scatter plots, but this does not seem to have an effect on the markers.
When I change the colour of the markers using the PZPlot properties Object, I see the color definition of the markers in both scatter plots change, and I can also see that the colours change if I directly access the properties and change the colour, but the plot isn’t drawn with those correct colors.
I tried using refresh after changing the values, but that doesn’t have any effect either.
See my code below:
s = tf(‘s’);
f = (1 + 1/s)
pzp = pzplot(f);
% See https://ch.mathworks.com/help/ident/ref/controllib.chart.pzplot-properties.html for new PZPlot-properties object
pzp.Responses.MarkerSize = 10;
pzp.Responses.LineWidth = 2;
%pzp.Responses.Color = ‘green’; % Changes colour of all markers
oPole = findobj(gca, ‘Tag’, ‘PZPoleScatter’);
oPole.MarkerEdgeColor = ‘red’;
oZero = findobj(gca, ‘Tag’, ‘PZZeroScatter’);
oZero.MarkerEdgeColor = ‘blue’;
rsp = findobj(gca, ‘Tag’, ‘PZPoleScatter’); % read object again to see if properties got changed correctly
I also found the following two topics, but they do not work anymore as there is no "Line" child in the PZPlot object.
https://ch.mathworks.com/matlabcentral/answers/276605-change-pzplot-marker-size
https://ch.mathworks.com/matlabcentral/answers/431293-i-am-using-pole-zero-map-pzmap-and-i-want-to-enhance-the-size-of-pole-or-zero-or-in-other-words-iHello everyone
I’m trying to change the marker color in the pzplot graph. I’m using version 2024b.
Apparently, in this version, a new object(?) called "PZPlot Properties" was introduced, which is great.
Using this new object, I can easily change the size and line thickness of all markers. But I can also only change the colour of all markers. I’d like to change the colours of the markers for the poles and zeros separately.
I tried using the "findobj" method and found, that the PZPlot apparently consists of two Scatter-Plots called "PZPoleScatter" and "PZZeroScatter", and I tried changing the color of the markers in those Scatter plots, but this does not seem to have an effect on the markers.
When I change the colour of the markers using the PZPlot properties Object, I see the color definition of the markers in both scatter plots change, and I can also see that the colours change if I directly access the properties and change the colour, but the plot isn’t drawn with those correct colors.
I tried using refresh after changing the values, but that doesn’t have any effect either.
See my code below:
s = tf(‘s’);
f = (1 + 1/s)
pzp = pzplot(f);
% See https://ch.mathworks.com/help/ident/ref/controllib.chart.pzplot-properties.html for new PZPlot-properties object
pzp.Responses.MarkerSize = 10;
pzp.Responses.LineWidth = 2;
%pzp.Responses.Color = ‘green’; % Changes colour of all markers
oPole = findobj(gca, ‘Tag’, ‘PZPoleScatter’);
oPole.MarkerEdgeColor = ‘red’;
oZero = findobj(gca, ‘Tag’, ‘PZZeroScatter’);
oZero.MarkerEdgeColor = ‘blue’;
rsp = findobj(gca, ‘Tag’, ‘PZPoleScatter’); % read object again to see if properties got changed correctly
I also found the following two topics, but they do not work anymore as there is no "Line" child in the PZPlot object.
https://ch.mathworks.com/matlabcentral/answers/276605-change-pzplot-marker-size
https://ch.mathworks.com/matlabcentral/answers/431293-i-am-using-pole-zero-map-pzmap-and-i-want-to-enhance-the-size-of-pole-or-zero-or-in-other-words-i Hello everyone
I’m trying to change the marker color in the pzplot graph. I’m using version 2024b.
Apparently, in this version, a new object(?) called "PZPlot Properties" was introduced, which is great.
Using this new object, I can easily change the size and line thickness of all markers. But I can also only change the colour of all markers. I’d like to change the colours of the markers for the poles and zeros separately.
I tried using the "findobj" method and found, that the PZPlot apparently consists of two Scatter-Plots called "PZPoleScatter" and "PZZeroScatter", and I tried changing the color of the markers in those Scatter plots, but this does not seem to have an effect on the markers.
When I change the colour of the markers using the PZPlot properties Object, I see the color definition of the markers in both scatter plots change, and I can also see that the colours change if I directly access the properties and change the colour, but the plot isn’t drawn with those correct colors.
I tried using refresh after changing the values, but that doesn’t have any effect either.
See my code below:
s = tf(‘s’);
f = (1 + 1/s)
pzp = pzplot(f);
% See https://ch.mathworks.com/help/ident/ref/controllib.chart.pzplot-properties.html for new PZPlot-properties object
pzp.Responses.MarkerSize = 10;
pzp.Responses.LineWidth = 2;
%pzp.Responses.Color = ‘green’; % Changes colour of all markers
oPole = findobj(gca, ‘Tag’, ‘PZPoleScatter’);
oPole.MarkerEdgeColor = ‘red’;
oZero = findobj(gca, ‘Tag’, ‘PZZeroScatter’);
oZero.MarkerEdgeColor = ‘blue’;
rsp = findobj(gca, ‘Tag’, ‘PZPoleScatter’); % read object again to see if properties got changed correctly
I also found the following two topics, but they do not work anymore as there is no "Line" child in the PZPlot object.
https://ch.mathworks.com/matlabcentral/answers/276605-change-pzplot-marker-size
https://ch.mathworks.com/matlabcentral/answers/431293-i-am-using-pole-zero-map-pzmap-and-i-want-to-enhance-the-size-of-pole-or-zero-or-in-other-words-i pzplot, marker, customization MATLAB Answers — New Questions
Extracting values from .xml files
Dear MATLAB users,
Kindly assist me on how to extract some data from .xml file here https://drive.google.com/file/d/1Sa1ycUqO4CshesnA_BAXy_BWGbeFb8IQ/view?usp=drive_link
Below is a part copied from the file. I would like specifically extract the values in BOLD
<CouchVrt>-176.51000000000011</CouchVrt>
<CouchLng>911.7700000000001</CouchLng>
<CouchLat>22.300999999999789</CouchLat>
I have been trying to read the file using xmlread without success.
Thanks in advance.Dear MATLAB users,
Kindly assist me on how to extract some data from .xml file here https://drive.google.com/file/d/1Sa1ycUqO4CshesnA_BAXy_BWGbeFb8IQ/view?usp=drive_link
Below is a part copied from the file. I would like specifically extract the values in BOLD
<CouchVrt>-176.51000000000011</CouchVrt>
<CouchLng>911.7700000000001</CouchLng>
<CouchLat>22.300999999999789</CouchLat>
I have been trying to read the file using xmlread without success.
Thanks in advance. Dear MATLAB users,
Kindly assist me on how to extract some data from .xml file here https://drive.google.com/file/d/1Sa1ycUqO4CshesnA_BAXy_BWGbeFb8IQ/view?usp=drive_link
Below is a part copied from the file. I would like specifically extract the values in BOLD
<CouchVrt>-176.51000000000011</CouchVrt>
<CouchLng>911.7700000000001</CouchLng>
<CouchLat>22.300999999999789</CouchLat>
I have been trying to read the file using xmlread without success.
Thanks in advance. xml files, text file read MATLAB Answers — New Questions
How to counting RBC size and number
i write this code but i cant get number of rbc and this is my input image
clear all;
close all;
clc;
count=0;
RC_Im = imread(‘red_cells.png’);
RC_Im = rgb2gray(RC_Im);
level=graythresh(RC_Im);
RC_Im_BW = im2bw(RC_Im,level);
figure;
imshow(RC_Im_BW,[])
[x,z]=size(RC_Im_BW);
for R=0:1:60
SE = strel(‘disk’,R);
afteropen=imopen(RC_Im_BW,SE);
if RC_Im_BW==1
count=count+1;
end
end
figure;
imshow(afteropen,[])i write this code but i cant get number of rbc and this is my input image
clear all;
close all;
clc;
count=0;
RC_Im = imread(‘red_cells.png’);
RC_Im = rgb2gray(RC_Im);
level=graythresh(RC_Im);
RC_Im_BW = im2bw(RC_Im,level);
figure;
imshow(RC_Im_BW,[])
[x,z]=size(RC_Im_BW);
for R=0:1:60
SE = strel(‘disk’,R);
afteropen=imopen(RC_Im_BW,SE);
if RC_Im_BW==1
count=count+1;
end
end
figure;
imshow(afteropen,[]) i write this code but i cant get number of rbc and this is my input image
clear all;
close all;
clc;
count=0;
RC_Im = imread(‘red_cells.png’);
RC_Im = rgb2gray(RC_Im);
level=graythresh(RC_Im);
RC_Im_BW = im2bw(RC_Im,level);
figure;
imshow(RC_Im_BW,[])
[x,z]=size(RC_Im_BW);
for R=0:1:60
SE = strel(‘disk’,R);
afteropen=imopen(RC_Im_BW,SE);
if RC_Im_BW==1
count=count+1;
end
end
figure;
imshow(afteropen,[]) imopen, rbc, loop, se MATLAB Answers — New Questions
Fit a standard Exponential fit to approximate data
1. For every exponential shaped signals, I want to fit a standard exponential decay fit (I’ve drawn in black) by joining the possible points in the green line. Also I need the count of such fits in the plot along with the duration of each.
2. I want to find out the slope (I’ve drawn in violet colour with a question mark) by drawing a line (I’ve drawn in dark cyan) that connects the starting and ending point of the standard fit. How to do?
Herewith I’ve attached the excel sheet and the code that i’ve tried so far.
clc; close all; clear all;
a=readtable(‘Data.xlsx’);
time=a{2:40000,1};amplitude=a{2:40000,3};
max_peak_values = [];
max_peak_locs = [];
window_size = 1000;
for i = 1:window_size:length(amplitude)
end_index = min(i + window_size – 1, length(amplitude));
segment = amplitude(i:end_index);
[max_peak, loc] = max(segment);
max_peak_values = [max_peak_values; max_peak];
max_peak_locs = [max_peak_locs; loc + i – 1];
end
joined_signal = zeros(size(amplitude));
joined_signal(max_peak_locs) = max_peak_values;
for j = 1:length(max_peak_locs)-1
x = [max_peak_locs(j), max_peak_locs(j+1)];
y = [max_peak_values(j), max_peak_values(j+1)];
interp_x = x(1):x(2);
interp_y = linspace(y(1), y(2), length(interp_x));
joined_signal(interp_x) = interp_y;
end
figure;
plot(time, amplitude, ‘b’);
hold on; grid on
plot(time(max_peak_locs), max_peak_values, ‘ro’);
plot(time, joined_signal, ‘g’);1. For every exponential shaped signals, I want to fit a standard exponential decay fit (I’ve drawn in black) by joining the possible points in the green line. Also I need the count of such fits in the plot along with the duration of each.
2. I want to find out the slope (I’ve drawn in violet colour with a question mark) by drawing a line (I’ve drawn in dark cyan) that connects the starting and ending point of the standard fit. How to do?
Herewith I’ve attached the excel sheet and the code that i’ve tried so far.
clc; close all; clear all;
a=readtable(‘Data.xlsx’);
time=a{2:40000,1};amplitude=a{2:40000,3};
max_peak_values = [];
max_peak_locs = [];
window_size = 1000;
for i = 1:window_size:length(amplitude)
end_index = min(i + window_size – 1, length(amplitude));
segment = amplitude(i:end_index);
[max_peak, loc] = max(segment);
max_peak_values = [max_peak_values; max_peak];
max_peak_locs = [max_peak_locs; loc + i – 1];
end
joined_signal = zeros(size(amplitude));
joined_signal(max_peak_locs) = max_peak_values;
for j = 1:length(max_peak_locs)-1
x = [max_peak_locs(j), max_peak_locs(j+1)];
y = [max_peak_values(j), max_peak_values(j+1)];
interp_x = x(1):x(2);
interp_y = linspace(y(1), y(2), length(interp_x));
joined_signal(interp_x) = interp_y;
end
figure;
plot(time, amplitude, ‘b’);
hold on; grid on
plot(time(max_peak_locs), max_peak_values, ‘ro’);
plot(time, joined_signal, ‘g’); 1. For every exponential shaped signals, I want to fit a standard exponential decay fit (I’ve drawn in black) by joining the possible points in the green line. Also I need the count of such fits in the plot along with the duration of each.
2. I want to find out the slope (I’ve drawn in violet colour with a question mark) by drawing a line (I’ve drawn in dark cyan) that connects the starting and ending point of the standard fit. How to do?
Herewith I’ve attached the excel sheet and the code that i’ve tried so far.
clc; close all; clear all;
a=readtable(‘Data.xlsx’);
time=a{2:40000,1};amplitude=a{2:40000,3};
max_peak_values = [];
max_peak_locs = [];
window_size = 1000;
for i = 1:window_size:length(amplitude)
end_index = min(i + window_size – 1, length(amplitude));
segment = amplitude(i:end_index);
[max_peak, loc] = max(segment);
max_peak_values = [max_peak_values; max_peak];
max_peak_locs = [max_peak_locs; loc + i – 1];
end
joined_signal = zeros(size(amplitude));
joined_signal(max_peak_locs) = max_peak_values;
for j = 1:length(max_peak_locs)-1
x = [max_peak_locs(j), max_peak_locs(j+1)];
y = [max_peak_values(j), max_peak_values(j+1)];
interp_x = x(1):x(2);
interp_y = linspace(y(1), y(2), length(interp_x));
joined_signal(interp_x) = interp_y;
end
figure;
plot(time, amplitude, ‘b’);
hold on; grid on
plot(time(max_peak_locs), max_peak_values, ‘ro’);
plot(time, joined_signal, ‘g’); exponential fit MATLAB Answers — New Questions
Genetic Algorithm Custom Output
Hello, I’m trying to optimize a simple Simulink model output by using Genetic Algorithm. Three different output values are implemented in this model. The first one is used as cost value. Hovewer, the other two values are not assigned to anything. I want to get these outputs as timeseries after the Genetic Algorithm calculations, like "The second output of Generation XX Individual YY is …". When the calculations are done with single core, I can get all the results I want, but when the parallel toolbox is used, only the last generation and last individual is visible after the calculations. How can I fix that parallel calculation? Here is my simple code that gives all individuals and cost values for me, but I need the other two outputs of simulation. Thanks.
clear all;clc;,
%%
tic
saveFlag = 0;
rng(‘shuffle’);
objectiveFunction = @(params) nlaSimResults(params);
lowerBound = [1000 0.2];
upperBound = [25000 0.8];
popSize = 10;
genSize = 20;
options = optimoptions(‘ga’,’UseParallel’,true,’UseVectorized’,false,’PopulationSize’,popSize,’MaxGenerations’,genSize,’OutputFcn’,@gaOutputFunction,’Display’,’iter’);
[bestParams, minCost, ~, optResults, optPop, optScores] = ga(objectiveFunction,2,[],[],[],[],lowerBound,upperBound,[],options);
optimTime = toc;
if saveFlag == 1; save(‘OptimResulst’,’bestParams’,’minCost’,’optResults’,’optScores’,’optimTime’,’popSize’,’genSize’); end
function cost = nlaSimResults(params)
global otherVars
Altitude = params(1);
Mach = params(2);
assignin(‘base’,’Altitude’,Altitude);
assignin(‘base’,’Mach’,Mach);
sim(‘debugModel’,10); % Simulation Model with Altitude and Mach inputs
cost = logsout{1}.Values.Data(1); % The first output of the model is assigned as cost
if isempty(otherVars)
otherVars = {};
end
otherVars = [otherVars; logsout{2}.Values.Data logsout{3}.Values.Data];
assignin(‘base’,’otherVars’,otherVars);
end
function [state, options, flag] = gaOutputFunction(options, state, flag)
persistent popHistory bestValues bestIndividuals otherVarsHistory
global otherVars
if isempty(popHistory)
popHistory = {};
bestValues = [];
bestIndividuals = [];
otherVarsHistory = {};
end
[bestScore, bestIdx] = min(state.Score);
bestValues = [bestValues; bestScore];
bestIndividuals = [bestIndividuals; state.Population(bestIdx, :)];
popHistory(state.Generation + 1) = {state.Population};
otherVarsHistory{state.Generation + 1} = otherVars;
otherVars = [];
assignin(‘base’,’popHistory’,popHistory);
assignin(‘base’,’bestValues’,bestValues);
assignin(‘base’,’bestIndividuals’,bestIndividuals);
assignin(‘base’,’otherVarsHistory’,otherVarsHistory);
end
My model is so simple, just returning the sum, product and division of the altitude and mach values.Hello, I’m trying to optimize a simple Simulink model output by using Genetic Algorithm. Three different output values are implemented in this model. The first one is used as cost value. Hovewer, the other two values are not assigned to anything. I want to get these outputs as timeseries after the Genetic Algorithm calculations, like "The second output of Generation XX Individual YY is …". When the calculations are done with single core, I can get all the results I want, but when the parallel toolbox is used, only the last generation and last individual is visible after the calculations. How can I fix that parallel calculation? Here is my simple code that gives all individuals and cost values for me, but I need the other two outputs of simulation. Thanks.
clear all;clc;,
%%
tic
saveFlag = 0;
rng(‘shuffle’);
objectiveFunction = @(params) nlaSimResults(params);
lowerBound = [1000 0.2];
upperBound = [25000 0.8];
popSize = 10;
genSize = 20;
options = optimoptions(‘ga’,’UseParallel’,true,’UseVectorized’,false,’PopulationSize’,popSize,’MaxGenerations’,genSize,’OutputFcn’,@gaOutputFunction,’Display’,’iter’);
[bestParams, minCost, ~, optResults, optPop, optScores] = ga(objectiveFunction,2,[],[],[],[],lowerBound,upperBound,[],options);
optimTime = toc;
if saveFlag == 1; save(‘OptimResulst’,’bestParams’,’minCost’,’optResults’,’optScores’,’optimTime’,’popSize’,’genSize’); end
function cost = nlaSimResults(params)
global otherVars
Altitude = params(1);
Mach = params(2);
assignin(‘base’,’Altitude’,Altitude);
assignin(‘base’,’Mach’,Mach);
sim(‘debugModel’,10); % Simulation Model with Altitude and Mach inputs
cost = logsout{1}.Values.Data(1); % The first output of the model is assigned as cost
if isempty(otherVars)
otherVars = {};
end
otherVars = [otherVars; logsout{2}.Values.Data logsout{3}.Values.Data];
assignin(‘base’,’otherVars’,otherVars);
end
function [state, options, flag] = gaOutputFunction(options, state, flag)
persistent popHistory bestValues bestIndividuals otherVarsHistory
global otherVars
if isempty(popHistory)
popHistory = {};
bestValues = [];
bestIndividuals = [];
otherVarsHistory = {};
end
[bestScore, bestIdx] = min(state.Score);
bestValues = [bestValues; bestScore];
bestIndividuals = [bestIndividuals; state.Population(bestIdx, :)];
popHistory(state.Generation + 1) = {state.Population};
otherVarsHistory{state.Generation + 1} = otherVars;
otherVars = [];
assignin(‘base’,’popHistory’,popHistory);
assignin(‘base’,’bestValues’,bestValues);
assignin(‘base’,’bestIndividuals’,bestIndividuals);
assignin(‘base’,’otherVarsHistory’,otherVarsHistory);
end
My model is so simple, just returning the sum, product and division of the altitude and mach values. Hello, I’m trying to optimize a simple Simulink model output by using Genetic Algorithm. Three different output values are implemented in this model. The first one is used as cost value. Hovewer, the other two values are not assigned to anything. I want to get these outputs as timeseries after the Genetic Algorithm calculations, like "The second output of Generation XX Individual YY is …". When the calculations are done with single core, I can get all the results I want, but when the parallel toolbox is used, only the last generation and last individual is visible after the calculations. How can I fix that parallel calculation? Here is my simple code that gives all individuals and cost values for me, but I need the other two outputs of simulation. Thanks.
clear all;clc;,
%%
tic
saveFlag = 0;
rng(‘shuffle’);
objectiveFunction = @(params) nlaSimResults(params);
lowerBound = [1000 0.2];
upperBound = [25000 0.8];
popSize = 10;
genSize = 20;
options = optimoptions(‘ga’,’UseParallel’,true,’UseVectorized’,false,’PopulationSize’,popSize,’MaxGenerations’,genSize,’OutputFcn’,@gaOutputFunction,’Display’,’iter’);
[bestParams, minCost, ~, optResults, optPop, optScores] = ga(objectiveFunction,2,[],[],[],[],lowerBound,upperBound,[],options);
optimTime = toc;
if saveFlag == 1; save(‘OptimResulst’,’bestParams’,’minCost’,’optResults’,’optScores’,’optimTime’,’popSize’,’genSize’); end
function cost = nlaSimResults(params)
global otherVars
Altitude = params(1);
Mach = params(2);
assignin(‘base’,’Altitude’,Altitude);
assignin(‘base’,’Mach’,Mach);
sim(‘debugModel’,10); % Simulation Model with Altitude and Mach inputs
cost = logsout{1}.Values.Data(1); % The first output of the model is assigned as cost
if isempty(otherVars)
otherVars = {};
end
otherVars = [otherVars; logsout{2}.Values.Data logsout{3}.Values.Data];
assignin(‘base’,’otherVars’,otherVars);
end
function [state, options, flag] = gaOutputFunction(options, state, flag)
persistent popHistory bestValues bestIndividuals otherVarsHistory
global otherVars
if isempty(popHistory)
popHistory = {};
bestValues = [];
bestIndividuals = [];
otherVarsHistory = {};
end
[bestScore, bestIdx] = min(state.Score);
bestValues = [bestValues; bestScore];
bestIndividuals = [bestIndividuals; state.Population(bestIdx, :)];
popHistory(state.Generation + 1) = {state.Population};
otherVarsHistory{state.Generation + 1} = otherVars;
otherVars = [];
assignin(‘base’,’popHistory’,popHistory);
assignin(‘base’,’bestValues’,bestValues);
assignin(‘base’,’bestIndividuals’,bestIndividuals);
assignin(‘base’,’otherVarsHistory’,otherVarsHistory);
end
My model is so simple, just returning the sum, product and division of the altitude and mach values. genetic algorithm, parallel computing toolbox MATLAB Answers — New Questions
Discrepancy in EPSG:3003 Coordinate Conversion Results in MATLAB
Hi everyone,
I need to convert latitude and longitude coordinates to the EPSG:3003 coordinate system. I have written the following lines of code:
proj3003 = projcrs(3003);
posLLH = [43.7918028 11.2474672 0];
[posEPSG3003(1), posEPSG3003(2)] = projfwd(proj3003, posLLH(1), posLLH(2));
I get the following result:
posEPSG3003 = [1680827.953610798, 4851292.727994160]
However, when I use an online tool like the one at EPSG.io, I get:
posEPSG3003 = [1680850, 4851220]
Can anyone explain the reason for this discrepancy?
Thank you in advance for your help!Hi everyone,
I need to convert latitude and longitude coordinates to the EPSG:3003 coordinate system. I have written the following lines of code:
proj3003 = projcrs(3003);
posLLH = [43.7918028 11.2474672 0];
[posEPSG3003(1), posEPSG3003(2)] = projfwd(proj3003, posLLH(1), posLLH(2));
I get the following result:
posEPSG3003 = [1680827.953610798, 4851292.727994160]
However, when I use an online tool like the one at EPSG.io, I get:
posEPSG3003 = [1680850, 4851220]
Can anyone explain the reason for this discrepancy?
Thank you in advance for your help! Hi everyone,
I need to convert latitude and longitude coordinates to the EPSG:3003 coordinate system. I have written the following lines of code:
proj3003 = projcrs(3003);
posLLH = [43.7918028 11.2474672 0];
[posEPSG3003(1), posEPSG3003(2)] = projfwd(proj3003, posLLH(1), posLLH(2));
I get the following result:
posEPSG3003 = [1680827.953610798, 4851292.727994160]
However, when I use an online tool like the one at EPSG.io, I get:
posEPSG3003 = [1680850, 4851220]
Can anyone explain the reason for this discrepancy?
Thank you in advance for your help! projfwd, projcrs, tiff, geotiff, matlab, llh, latitude, longitude, conversion, coordinates MATLAB Answers — New Questions
Error when trying to plot 3D Joint PDF
I’m suppose to plot the 3D Joint PDF of these two functions and compare it to the 3D Joint PDF of gaussian normal distribution, so I mulitplied them together but when I try to plot them I’m getting the (Z must be a matrix, not a scalar or vector error).
Question:
Code:
>> mu = 0;sigma = 1; %mean = 0, variance = 1
>> L = 100000; %length of random vector
>> x1 = rand(L,1); %x1 uniformly distributed U(0,1)
>> x2 = rand(L,1); %x2 uniformly distributed U(0,1)
>> w1 = sqrt(-2*log(x1)).*cos(2*pi*x2); %w1 pdf declared
>> w2 = sqrt(-2*log(x1)).*sin(2*pi*x2); %w2 pdf declared
>> w = w1.*w2; %joint pdf declared
>> X = -10:0.1:10;
>> Y = X;
>> gaussNormal = pdf(‘Normal’,X,mu,sigma); %declare gaussian normal pdf
>> [x,y] = meshgrid[X,Y];
>> mesh(x,y,w);
Error using mesh (line 71)
Z must be a matrix, not a scalar or vector.I’m suppose to plot the 3D Joint PDF of these two functions and compare it to the 3D Joint PDF of gaussian normal distribution, so I mulitplied them together but when I try to plot them I’m getting the (Z must be a matrix, not a scalar or vector error).
Question:
Code:
>> mu = 0;sigma = 1; %mean = 0, variance = 1
>> L = 100000; %length of random vector
>> x1 = rand(L,1); %x1 uniformly distributed U(0,1)
>> x2 = rand(L,1); %x2 uniformly distributed U(0,1)
>> w1 = sqrt(-2*log(x1)).*cos(2*pi*x2); %w1 pdf declared
>> w2 = sqrt(-2*log(x1)).*sin(2*pi*x2); %w2 pdf declared
>> w = w1.*w2; %joint pdf declared
>> X = -10:0.1:10;
>> Y = X;
>> gaussNormal = pdf(‘Normal’,X,mu,sigma); %declare gaussian normal pdf
>> [x,y] = meshgrid[X,Y];
>> mesh(x,y,w);
Error using mesh (line 71)
Z must be a matrix, not a scalar or vector. I’m suppose to plot the 3D Joint PDF of these two functions and compare it to the 3D Joint PDF of gaussian normal distribution, so I mulitplied them together but when I try to plot them I’m getting the (Z must be a matrix, not a scalar or vector error).
Question:
Code:
>> mu = 0;sigma = 1; %mean = 0, variance = 1
>> L = 100000; %length of random vector
>> x1 = rand(L,1); %x1 uniformly distributed U(0,1)
>> x2 = rand(L,1); %x2 uniformly distributed U(0,1)
>> w1 = sqrt(-2*log(x1)).*cos(2*pi*x2); %w1 pdf declared
>> w2 = sqrt(-2*log(x1)).*sin(2*pi*x2); %w2 pdf declared
>> w = w1.*w2; %joint pdf declared
>> X = -10:0.1:10;
>> Y = X;
>> gaussNormal = pdf(‘Normal’,X,mu,sigma); %declare gaussian normal pdf
>> [x,y] = meshgrid[X,Y];
>> mesh(x,y,w);
Error using mesh (line 71)
Z must be a matrix, not a scalar or vector. mesh error pdf joint gaussian normal uniform distribution MATLAB Answers — New Questions
how can i hidder(or enable=’off’) tab2?
Post Content Post Content how can i hidder(or enable=’off’) then tab2? MATLAB Answers — New Questions
Interaction MATLAB-C++ and toolboxes
Hi there,
Sorry if this is a newbie question but I’d like to get my ideas straight before start doing what I want to.
I understand there’s a way to use MATLAB code in C++ (i.e. calling it from C++). But my questions are:
– I have a bunch of functions all of which called by a script, is possible to call such script and retrieve the output. I can also wrap the script around another functions, but still, can I call a function that call another function (and so forth) even if those are in different files?
– I am in extreme needs of the image toolbox in my functions. Is this possible in the moment I call the code from C++?
– In which format I can obtain the output. Can I just map a MATLAB matrix in a C++ matrix?
– Can I pass the code an Image from C++ as a unsigned char matrix?
I understand there may be a documentation out there about this, but I found very fragmented sources, can you in case link me to a good one?
Thank you very muchHi there,
Sorry if this is a newbie question but I’d like to get my ideas straight before start doing what I want to.
I understand there’s a way to use MATLAB code in C++ (i.e. calling it from C++). But my questions are:
– I have a bunch of functions all of which called by a script, is possible to call such script and retrieve the output. I can also wrap the script around another functions, but still, can I call a function that call another function (and so forth) even if those are in different files?
– I am in extreme needs of the image toolbox in my functions. Is this possible in the moment I call the code from C++?
– In which format I can obtain the output. Can I just map a MATLAB matrix in a C++ matrix?
– Can I pass the code an Image from C++ as a unsigned char matrix?
I understand there may be a documentation out there about this, but I found very fragmented sources, can you in case link me to a good one?
Thank you very much Hi there,
Sorry if this is a newbie question but I’d like to get my ideas straight before start doing what I want to.
I understand there’s a way to use MATLAB code in C++ (i.e. calling it from C++). But my questions are:
– I have a bunch of functions all of which called by a script, is possible to call such script and retrieve the output. I can also wrap the script around another functions, but still, can I call a function that call another function (and so forth) even if those are in different files?
– I am in extreme needs of the image toolbox in my functions. Is this possible in the moment I call the code from C++?
– In which format I can obtain the output. Can I just map a MATLAB matrix in a C++ matrix?
– Can I pass the code an Image from C++ as a unsigned char matrix?
I understand there may be a documentation out there about this, but I found very fragmented sources, can you in case link me to a good one?
Thank you very much c++ MATLAB Answers — New Questions
MATLAB icon not showing in Ubuntu while running!!
I have installed MATLAB 2022b on Ubuntu 24.04.01. I could install MATLAB, and the launcher using sudo apt-get install matlab-support, Shortcut works fine and shortcut has MATLAB icon. The MATLAB also works fine and fast.
However, I cannot see MATLAB icon on the dock (taskbar), while it is runnig, instead I can see a gear icon (like settings icon). This is very confusing while running multiple applications, there is also a chance of wrongly closing the application.
Thanks in advance.I have installed MATLAB 2022b on Ubuntu 24.04.01. I could install MATLAB, and the launcher using sudo apt-get install matlab-support, Shortcut works fine and shortcut has MATLAB icon. The MATLAB also works fine and fast.
However, I cannot see MATLAB icon on the dock (taskbar), while it is runnig, instead I can see a gear icon (like settings icon). This is very confusing while running multiple applications, there is also a chance of wrongly closing the application.
Thanks in advance. I have installed MATLAB 2022b on Ubuntu 24.04.01. I could install MATLAB, and the launcher using sudo apt-get install matlab-support, Shortcut works fine and shortcut has MATLAB icon. The MATLAB also works fine and fast.
However, I cannot see MATLAB icon on the dock (taskbar), while it is runnig, instead I can see a gear icon (like settings icon). This is very confusing while running multiple applications, there is also a chance of wrongly closing the application.
Thanks in advance. icon not showing, matlab icon missing, confusing like settings icon MATLAB Answers — New Questions
The problem about Simscape Battery MBC parameter estimate.
I am trying to calibrate my battery parameters using the MBC tool, but I encountered the following issue. I input the HPPC experimental data into the MBC tool and waited for it to fit the parameters, such as Em, R0, R1, etc. However, the results were disappointing. The fitting did not converge, and the curve could not be fitted at all. The result is shown in Figure 1 below. Could you please help me identify the issue? Is it a problem with my parameter settings in the MBC tool, or is there an issue with my HPPC experimental data?I am trying to calibrate my battery parameters using the MBC tool, but I encountered the following issue. I input the HPPC experimental data into the MBC tool and waited for it to fit the parameters, such as Em, R0, R1, etc. However, the results were disappointing. The fitting did not converge, and the curve could not be fitted at all. The result is shown in Figure 1 below. Could you please help me identify the issue? Is it a problem with my parameter settings in the MBC tool, or is there an issue with my HPPC experimental data? I am trying to calibrate my battery parameters using the MBC tool, but I encountered the following issue. I input the HPPC experimental data into the MBC tool and waited for it to fit the parameters, such as Em, R0, R1, etc. However, the results were disappointing. The fitting did not converge, and the curve could not be fitted at all. The result is shown in Figure 1 below. Could you please help me identify the issue? Is it a problem with my parameter settings in the MBC tool, or is there an issue with my HPPC experimental data? simscape, mbc, battery_system_management MATLAB Answers — New Questions
Code inspector not able to verify the state flow model
I am able to run model and generate the code, but when i run the code inspector, not able to varifiy the code, its failing
Please let me know, anyone faced this issue beforeI am able to run model and generate the code, but when i run the code inspector, not able to varifiy the code, its failing
Please let me know, anyone faced this issue before I am able to run model and generate the code, but when i run the code inspector, not able to varifiy the code, its failing
Please let me know, anyone faced this issue before state flow not able to verify the state flow chart MATLAB Answers — New Questions
C++ compiler errors TFlite
Good afternoon,
I have been trying to deploy a tflite model onto my raspberry pi using MATLAB 2024a.
To start i am using:
Example code (SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample).
Mex code setup i am using ‘Microsoft Visual C++ 2022’
Built Tensorflow 2.15 on Windows with Bazel 6.10
Downloaded and setup Raspberry pi Matlab config
Raspberry pi 32 bit bullseye (python 3.9.2)
created all of the paths accordingly as stated in Prerequisites for Deep Learning with TensorFlow Lite Models
When i run the code it has no errors. The problem starts once i run:
codegen -config cfg tflite_semantic_predict -args ones(257,257,3,’single’)
The error is as follows:
codegen -config cfg tflite_semantic_predict -args ones(257,257,3,’single’)
————————————————————————
Error executing command "touch -c /home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict/*.*;make -j$(($(nproc)+1)) -Otarget -f tflite_semantic_predict_rtw.mk all MATLAB_WORKSPACE="/home/bmblaylock42/MATLAB_ws/R2024a" LINUX_TARGET_LIBS_MACRO="" -C /home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict LC_ALL=C". Details:
STDERR: In file included from /home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/tflite_interface/invokeinterpreter/export/include/invokeinterpreter/tensorflow/lite/core/model.h:26,
from /home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/tflite_interface/invokeinterpreter/export/include/invokeinterpreter/tensorflow/lite/core/kernels/register.h:22,
from /home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/tflite_interface/invokeinterpreter/export/include/invokeinterpreter/kernels/register.h:18,
from /home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/tflite_interface/invokeinterpreter/export/include/invokeinterpreter/invokeinterpreter.hpp:16,
from /home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/tflite_interface/invokeinterpreter/invokeinterpreter.cpp:6:
/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/tflite_interface/invokeinterpreter/export/include/invokeinterpreter/tensorflow/lite/core/interpreter_builder.h:33:10: fatal error: flatbuffers/flatbuffers.h: No such file or directory
33 | #include "flatbuffers/flatbuffers.h"
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
make: *** [tflite_semantic_predict_rtw.mk:382: invokeinterpreter.cpp.o] Error 1
make: *** Waiting for unfinished jobs….
In file included from /home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/tflite_interface/invokeinterpreter/export/include/invokeinterpreter/tensorflow/lite/core/model.h:26,
from /home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/tflite_interface/invokeinterpreter/export/include/invokeinterpreter/tensorflow/lite/core/kernels/register.h:22,
from /home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/tflite_interface/invokeinterpreter/export/include/invokeinterpreter/kernels/register.h:18,
from /home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/tflite_interface/invokeinterpreter/export/include/invokeinterpreter/invokeinterpreter.hpp:16,
from /home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict/tflite_semantic_predict.cpp:15:
/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/tflite_interface/invokeinterpreter/export/include/invokeinterpreter/tensorflow/lite/core/interpreter_builder.h:33:10: fatal error: flatbuffers/flatbuffers.h: No such file or directory
33 | #include "flatbuffers/flatbuffers.h"
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
make: *** [tflite_semantic_predict_rtw.mk:398: tflite_semantic_predict.cpp.o] Error 1
STDOUT: make: Entering directory ‘/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict’
g++ -c -MMD -MP -MF"tflite_semantic_predict_data.cpp.dep" -MT"tflite_semantic_predict_data.cpp.o" -fpermissive -O2 -DMW_NUM_CORES=4 -pthread -fopenmp -std=c++17 -D__MW_TARGET_USE_HARDWARE_RESOURCES_H__ -D__linux__ -DARM_PROJECT -D_USE_TARGET_UDP_ -D_RUNONTARGETHARDWARE_BUILD_ -DSTACK_SIZE=200000 -DMODEL=tflite_semantic_predict -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/tflite_interface/invokeinterpreter/export/include/invokeinterpreter -I -I/tensorflow/lite -I/tensorflow/lite/tools/make/downloads/flatbuffers/include -I/flatbuffers/include -I/home/bmblaylock42/MATLAB_ws/R2024a/C/ProgramData/MATLAB/SupportPackages/R2024a/toolbox/realtime/targets/raspi/include -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/coder/rtiostream/src/utils -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/extern/include -o "tflite_semantic_predict_data.cpp.o" "/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict/tflite_semantic_predict_data.cpp"
make: Leaving directory ‘/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict’
make: Entering directory ‘/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict’
g++ -c -MMD -MP -MF"tflite_semantic_predict_terminate.cpp.dep" -MT"tflite_semantic_predict_terminate.cpp.o" -fpermissive -O2 -DMW_NUM_CORES=4 -pthread -fopenmp -std=c++17 -D__MW_TARGET_USE_HARDWARE_RESOURCES_H__ -D__linux__ -DARM_PROJECT -D_USE_TARGET_UDP_ -D_RUNONTARGETHARDWARE_BUILD_ -DSTACK_SIZE=200000 -DMODEL=tflite_semantic_predict -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/tflite_interface/invokeinterpreter/export/include/invokeinterpreter -I -I/tensorflow/lite -I/tensorflow/lite/tools/make/downloads/flatbuffers/include -I/flatbuffers/include -I/home/bmblaylock42/MATLAB_ws/R2024a/C/ProgramData/MATLAB/SupportPackages/R2024a/toolbox/realtime/targets/raspi/include -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/coder/rtiostream/src/utils -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/extern/include -o "tflite_semantic_predict_terminate.cpp.o" "/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict/tflite_semantic_predict_terminate.cpp"
make: Leaving directory ‘/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict’
make: Entering directory ‘/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict’
g++ -c -MMD -MP -MF"tflite_semantic_predict_initialize.cpp.dep" -MT"tflite_semantic_predict_initialize.cpp.o" -fpermissive -O2 -DMW_NUM_CORES=4 -pthread -fopenmp -std=c++17 -D__MW_TARGET_USE_HARDWARE_RESOURCES_H__ -D__linux__ -DARM_PROJECT -D_USE_TARGET_UDP_ -D_RUNONTARGETHARDWARE_BUILD_ -DSTACK_SIZE=200000 -DMODEL=tflite_semantic_predict -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/tflite_interface/invokeinterpreter/export/include/invokeinterpreter -I -I/tensorflow/lite -I/tensorflow/lite/tools/make/downloads/flatbuffers/include -I/flatbuffers/include -I/home/bmblaylock42/MATLAB_ws/R2024a/C/ProgramData/MATLAB/SupportPackages/R2024a/toolbox/realtime/targets/raspi/include -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/coder/rtiostream/src/utils -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/extern/include -o "tflite_semantic_predict_initialize.cpp.o" "/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict/tflite_semantic_predict_initialize.cpp"
make: Leaving directory ‘/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict’
make: Entering directory ‘/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict’
g++ -c -MMD -MP -MF"invokeinterpreter.cpp.dep" -MT"invokeinterpreter.cpp.o" -fpermissive -O2 -DMW_NUM_CORES=4 -pthread -fopenmp -std=c++17 -D__MW_TARGET_USE_HARDWARE_RESOURCES_H__ -D__linux__ -DARM_PROJECT -D_USE_TARGET_UDP_ -D_RUNONTARGETHARDWARE_BUILD_ -DSTACK_SIZE=200000 -DMODEL=tflite_semantic_predict -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/tflite_interface/invokeinterpreter/export/include/invokeinterpreter -I -I/tensorflow/lite -I/tensorflow/lite/tools/make/downloads/flatbuffers/include -I/flatbuffers/include -I/home/bmblaylock42/MATLAB_ws/R2024a/C/ProgramData/MATLAB/SupportPackages/R2024a/toolbox/realtime/targets/raspi/include -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/coder/rtiostream/src/utils -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/extern/include -o "invokeinterpreter.cpp.o" "/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/tflite_interface/invokeinterpreter/invokeinterpreter.cpp"
make: Leaving directory ‘/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict’
make: Entering directory ‘/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict’
g++ -c -MMD -MP -MF"tflite_semantic_predict.cpp.dep" -MT"tflite_semantic_predict.cpp.o" -fpermissive -O2 -DMW_NUM_CORES=4 -pthread -fopenmp -std=c++17 -D__MW_TARGET_USE_HARDWARE_RESOURCES_H__ -D__linux__ -DARM_PROJECT -D_USE_TARGET_UDP_ -D_RUNONTARGETHARDWARE_BUILD_ -DSTACK_SIZE=200000 -DMODEL=tflite_semantic_predict -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/tflite_interface/invokeinterpreter/export/include/invokeinterpreter -I -I/tensorflow/lite -I/tensorflow/lite/tools/make/downloads/flatbuffers/include -I/flatbuffers/include -I/home/bmblaylock42/MATLAB_ws/R2024a/C/ProgramData/MATLAB/SupportPackages/R2024a/toolbox/realtime/targets/raspi/include -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/coder/rtiostream/src/utils -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/extern/include -o "tflite_semantic_predict.cpp.o" "/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict/tflite_semantic_predict.cpp"
make: Leaving directory ‘/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict’
————————————————————————
Build error: C++ compiler produced errors. See the Build Log for further details.
More information
Code generation failed: View Error Report
Error using codegen
Thank you so much i have tried to download the flatbuffers by CMake and bazel but i had no luck since they are 64 bit codes and mine is a 32bit aarch64.Good afternoon,
I have been trying to deploy a tflite model onto my raspberry pi using MATLAB 2024a.
To start i am using:
Example code (SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample).
Mex code setup i am using ‘Microsoft Visual C++ 2022’
Built Tensorflow 2.15 on Windows with Bazel 6.10
Downloaded and setup Raspberry pi Matlab config
Raspberry pi 32 bit bullseye (python 3.9.2)
created all of the paths accordingly as stated in Prerequisites for Deep Learning with TensorFlow Lite Models
When i run the code it has no errors. The problem starts once i run:
codegen -config cfg tflite_semantic_predict -args ones(257,257,3,’single’)
The error is as follows:
codegen -config cfg tflite_semantic_predict -args ones(257,257,3,’single’)
————————————————————————
Error executing command "touch -c /home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict/*.*;make -j$(($(nproc)+1)) -Otarget -f tflite_semantic_predict_rtw.mk all MATLAB_WORKSPACE="/home/bmblaylock42/MATLAB_ws/R2024a" LINUX_TARGET_LIBS_MACRO="" -C /home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict LC_ALL=C". Details:
STDERR: In file included from /home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/tflite_interface/invokeinterpreter/export/include/invokeinterpreter/tensorflow/lite/core/model.h:26,
from /home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/tflite_interface/invokeinterpreter/export/include/invokeinterpreter/tensorflow/lite/core/kernels/register.h:22,
from /home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/tflite_interface/invokeinterpreter/export/include/invokeinterpreter/kernels/register.h:18,
from /home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/tflite_interface/invokeinterpreter/export/include/invokeinterpreter/invokeinterpreter.hpp:16,
from /home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/tflite_interface/invokeinterpreter/invokeinterpreter.cpp:6:
/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/tflite_interface/invokeinterpreter/export/include/invokeinterpreter/tensorflow/lite/core/interpreter_builder.h:33:10: fatal error: flatbuffers/flatbuffers.h: No such file or directory
33 | #include "flatbuffers/flatbuffers.h"
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
make: *** [tflite_semantic_predict_rtw.mk:382: invokeinterpreter.cpp.o] Error 1
make: *** Waiting for unfinished jobs….
In file included from /home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/tflite_interface/invokeinterpreter/export/include/invokeinterpreter/tensorflow/lite/core/model.h:26,
from /home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/tflite_interface/invokeinterpreter/export/include/invokeinterpreter/tensorflow/lite/core/kernels/register.h:22,
from /home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/tflite_interface/invokeinterpreter/export/include/invokeinterpreter/kernels/register.h:18,
from /home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/tflite_interface/invokeinterpreter/export/include/invokeinterpreter/invokeinterpreter.hpp:16,
from /home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict/tflite_semantic_predict.cpp:15:
/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/tflite_interface/invokeinterpreter/export/include/invokeinterpreter/tensorflow/lite/core/interpreter_builder.h:33:10: fatal error: flatbuffers/flatbuffers.h: No such file or directory
33 | #include "flatbuffers/flatbuffers.h"
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
make: *** [tflite_semantic_predict_rtw.mk:398: tflite_semantic_predict.cpp.o] Error 1
STDOUT: make: Entering directory ‘/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict’
g++ -c -MMD -MP -MF"tflite_semantic_predict_data.cpp.dep" -MT"tflite_semantic_predict_data.cpp.o" -fpermissive -O2 -DMW_NUM_CORES=4 -pthread -fopenmp -std=c++17 -D__MW_TARGET_USE_HARDWARE_RESOURCES_H__ -D__linux__ -DARM_PROJECT -D_USE_TARGET_UDP_ -D_RUNONTARGETHARDWARE_BUILD_ -DSTACK_SIZE=200000 -DMODEL=tflite_semantic_predict -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/tflite_interface/invokeinterpreter/export/include/invokeinterpreter -I -I/tensorflow/lite -I/tensorflow/lite/tools/make/downloads/flatbuffers/include -I/flatbuffers/include -I/home/bmblaylock42/MATLAB_ws/R2024a/C/ProgramData/MATLAB/SupportPackages/R2024a/toolbox/realtime/targets/raspi/include -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/coder/rtiostream/src/utils -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/extern/include -o "tflite_semantic_predict_data.cpp.o" "/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict/tflite_semantic_predict_data.cpp"
make: Leaving directory ‘/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict’
make: Entering directory ‘/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict’
g++ -c -MMD -MP -MF"tflite_semantic_predict_terminate.cpp.dep" -MT"tflite_semantic_predict_terminate.cpp.o" -fpermissive -O2 -DMW_NUM_CORES=4 -pthread -fopenmp -std=c++17 -D__MW_TARGET_USE_HARDWARE_RESOURCES_H__ -D__linux__ -DARM_PROJECT -D_USE_TARGET_UDP_ -D_RUNONTARGETHARDWARE_BUILD_ -DSTACK_SIZE=200000 -DMODEL=tflite_semantic_predict -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/tflite_interface/invokeinterpreter/export/include/invokeinterpreter -I -I/tensorflow/lite -I/tensorflow/lite/tools/make/downloads/flatbuffers/include -I/flatbuffers/include -I/home/bmblaylock42/MATLAB_ws/R2024a/C/ProgramData/MATLAB/SupportPackages/R2024a/toolbox/realtime/targets/raspi/include -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/coder/rtiostream/src/utils -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/extern/include -o "tflite_semantic_predict_terminate.cpp.o" "/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict/tflite_semantic_predict_terminate.cpp"
make: Leaving directory ‘/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict’
make: Entering directory ‘/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict’
g++ -c -MMD -MP -MF"tflite_semantic_predict_initialize.cpp.dep" -MT"tflite_semantic_predict_initialize.cpp.o" -fpermissive -O2 -DMW_NUM_CORES=4 -pthread -fopenmp -std=c++17 -D__MW_TARGET_USE_HARDWARE_RESOURCES_H__ -D__linux__ -DARM_PROJECT -D_USE_TARGET_UDP_ -D_RUNONTARGETHARDWARE_BUILD_ -DSTACK_SIZE=200000 -DMODEL=tflite_semantic_predict -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/tflite_interface/invokeinterpreter/export/include/invokeinterpreter -I -I/tensorflow/lite -I/tensorflow/lite/tools/make/downloads/flatbuffers/include -I/flatbuffers/include -I/home/bmblaylock42/MATLAB_ws/R2024a/C/ProgramData/MATLAB/SupportPackages/R2024a/toolbox/realtime/targets/raspi/include -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/coder/rtiostream/src/utils -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/extern/include -o "tflite_semantic_predict_initialize.cpp.o" "/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict/tflite_semantic_predict_initialize.cpp"
make: Leaving directory ‘/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict’
make: Entering directory ‘/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict’
g++ -c -MMD -MP -MF"invokeinterpreter.cpp.dep" -MT"invokeinterpreter.cpp.o" -fpermissive -O2 -DMW_NUM_CORES=4 -pthread -fopenmp -std=c++17 -D__MW_TARGET_USE_HARDWARE_RESOURCES_H__ -D__linux__ -DARM_PROJECT -D_USE_TARGET_UDP_ -D_RUNONTARGETHARDWARE_BUILD_ -DSTACK_SIZE=200000 -DMODEL=tflite_semantic_predict -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/tflite_interface/invokeinterpreter/export/include/invokeinterpreter -I -I/tensorflow/lite -I/tensorflow/lite/tools/make/downloads/flatbuffers/include -I/flatbuffers/include -I/home/bmblaylock42/MATLAB_ws/R2024a/C/ProgramData/MATLAB/SupportPackages/R2024a/toolbox/realtime/targets/raspi/include -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/coder/rtiostream/src/utils -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/extern/include -o "invokeinterpreter.cpp.o" "/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/tflite_interface/invokeinterpreter/invokeinterpreter.cpp"
make: Leaving directory ‘/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict’
make: Entering directory ‘/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict’
g++ -c -MMD -MP -MF"tflite_semantic_predict.cpp.dep" -MT"tflite_semantic_predict.cpp.o" -fpermissive -O2 -DMW_NUM_CORES=4 -pthread -fopenmp -std=c++17 -D__MW_TARGET_USE_HARDWARE_RESOURCES_H__ -D__linux__ -DARM_PROJECT -D_USE_TARGET_UDP_ -D_RUNONTARGETHARDWARE_BUILD_ -DSTACK_SIZE=200000 -DMODEL=tflite_semantic_predict -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/tflite_interface/invokeinterpreter/export/include/invokeinterpreter -I -I/tensorflow/lite -I/tensorflow/lite/tools/make/downloads/flatbuffers/include -I/flatbuffers/include -I/home/bmblaylock42/MATLAB_ws/R2024a/C/ProgramData/MATLAB/SupportPackages/R2024a/toolbox/realtime/targets/raspi/include -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/coder/rtiostream/src/utils -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/extern/include -o "tflite_semantic_predict.cpp.o" "/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict/tflite_semantic_predict.cpp"
make: Leaving directory ‘/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict’
————————————————————————
Build error: C++ compiler produced errors. See the Build Log for further details.
More information
Code generation failed: View Error Report
Error using codegen
Thank you so much i have tried to download the flatbuffers by CMake and bazel but i had no luck since they are 64 bit codes and mine is a 32bit aarch64. Good afternoon,
I have been trying to deploy a tflite model onto my raspberry pi using MATLAB 2024a.
To start i am using:
Example code (SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample).
Mex code setup i am using ‘Microsoft Visual C++ 2022’
Built Tensorflow 2.15 on Windows with Bazel 6.10
Downloaded and setup Raspberry pi Matlab config
Raspberry pi 32 bit bullseye (python 3.9.2)
created all of the paths accordingly as stated in Prerequisites for Deep Learning with TensorFlow Lite Models
When i run the code it has no errors. The problem starts once i run:
codegen -config cfg tflite_semantic_predict -args ones(257,257,3,’single’)
The error is as follows:
codegen -config cfg tflite_semantic_predict -args ones(257,257,3,’single’)
————————————————————————
Error executing command "touch -c /home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict/*.*;make -j$(($(nproc)+1)) -Otarget -f tflite_semantic_predict_rtw.mk all MATLAB_WORKSPACE="/home/bmblaylock42/MATLAB_ws/R2024a" LINUX_TARGET_LIBS_MACRO="" -C /home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict LC_ALL=C". Details:
STDERR: In file included from /home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/tflite_interface/invokeinterpreter/export/include/invokeinterpreter/tensorflow/lite/core/model.h:26,
from /home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/tflite_interface/invokeinterpreter/export/include/invokeinterpreter/tensorflow/lite/core/kernels/register.h:22,
from /home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/tflite_interface/invokeinterpreter/export/include/invokeinterpreter/kernels/register.h:18,
from /home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/tflite_interface/invokeinterpreter/export/include/invokeinterpreter/invokeinterpreter.hpp:16,
from /home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/tflite_interface/invokeinterpreter/invokeinterpreter.cpp:6:
/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/tflite_interface/invokeinterpreter/export/include/invokeinterpreter/tensorflow/lite/core/interpreter_builder.h:33:10: fatal error: flatbuffers/flatbuffers.h: No such file or directory
33 | #include "flatbuffers/flatbuffers.h"
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
make: *** [tflite_semantic_predict_rtw.mk:382: invokeinterpreter.cpp.o] Error 1
make: *** Waiting for unfinished jobs….
In file included from /home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/tflite_interface/invokeinterpreter/export/include/invokeinterpreter/tensorflow/lite/core/model.h:26,
from /home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/tflite_interface/invokeinterpreter/export/include/invokeinterpreter/tensorflow/lite/core/kernels/register.h:22,
from /home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/tflite_interface/invokeinterpreter/export/include/invokeinterpreter/kernels/register.h:18,
from /home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/tflite_interface/invokeinterpreter/export/include/invokeinterpreter/invokeinterpreter.hpp:16,
from /home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict/tflite_semantic_predict.cpp:15:
/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/tflite_interface/invokeinterpreter/export/include/invokeinterpreter/tensorflow/lite/core/interpreter_builder.h:33:10: fatal error: flatbuffers/flatbuffers.h: No such file or directory
33 | #include "flatbuffers/flatbuffers.h"
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
make: *** [tflite_semantic_predict_rtw.mk:398: tflite_semantic_predict.cpp.o] Error 1
STDOUT: make: Entering directory ‘/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict’
g++ -c -MMD -MP -MF"tflite_semantic_predict_data.cpp.dep" -MT"tflite_semantic_predict_data.cpp.o" -fpermissive -O2 -DMW_NUM_CORES=4 -pthread -fopenmp -std=c++17 -D__MW_TARGET_USE_HARDWARE_RESOURCES_H__ -D__linux__ -DARM_PROJECT -D_USE_TARGET_UDP_ -D_RUNONTARGETHARDWARE_BUILD_ -DSTACK_SIZE=200000 -DMODEL=tflite_semantic_predict -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/tflite_interface/invokeinterpreter/export/include/invokeinterpreter -I -I/tensorflow/lite -I/tensorflow/lite/tools/make/downloads/flatbuffers/include -I/flatbuffers/include -I/home/bmblaylock42/MATLAB_ws/R2024a/C/ProgramData/MATLAB/SupportPackages/R2024a/toolbox/realtime/targets/raspi/include -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/coder/rtiostream/src/utils -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/extern/include -o "tflite_semantic_predict_data.cpp.o" "/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict/tflite_semantic_predict_data.cpp"
make: Leaving directory ‘/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict’
make: Entering directory ‘/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict’
g++ -c -MMD -MP -MF"tflite_semantic_predict_terminate.cpp.dep" -MT"tflite_semantic_predict_terminate.cpp.o" -fpermissive -O2 -DMW_NUM_CORES=4 -pthread -fopenmp -std=c++17 -D__MW_TARGET_USE_HARDWARE_RESOURCES_H__ -D__linux__ -DARM_PROJECT -D_USE_TARGET_UDP_ -D_RUNONTARGETHARDWARE_BUILD_ -DSTACK_SIZE=200000 -DMODEL=tflite_semantic_predict -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/tflite_interface/invokeinterpreter/export/include/invokeinterpreter -I -I/tensorflow/lite -I/tensorflow/lite/tools/make/downloads/flatbuffers/include -I/flatbuffers/include -I/home/bmblaylock42/MATLAB_ws/R2024a/C/ProgramData/MATLAB/SupportPackages/R2024a/toolbox/realtime/targets/raspi/include -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/coder/rtiostream/src/utils -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/extern/include -o "tflite_semantic_predict_terminate.cpp.o" "/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict/tflite_semantic_predict_terminate.cpp"
make: Leaving directory ‘/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict’
make: Entering directory ‘/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict’
g++ -c -MMD -MP -MF"tflite_semantic_predict_initialize.cpp.dep" -MT"tflite_semantic_predict_initialize.cpp.o" -fpermissive -O2 -DMW_NUM_CORES=4 -pthread -fopenmp -std=c++17 -D__MW_TARGET_USE_HARDWARE_RESOURCES_H__ -D__linux__ -DARM_PROJECT -D_USE_TARGET_UDP_ -D_RUNONTARGETHARDWARE_BUILD_ -DSTACK_SIZE=200000 -DMODEL=tflite_semantic_predict -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/tflite_interface/invokeinterpreter/export/include/invokeinterpreter -I -I/tensorflow/lite -I/tensorflow/lite/tools/make/downloads/flatbuffers/include -I/flatbuffers/include -I/home/bmblaylock42/MATLAB_ws/R2024a/C/ProgramData/MATLAB/SupportPackages/R2024a/toolbox/realtime/targets/raspi/include -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/coder/rtiostream/src/utils -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/extern/include -o "tflite_semantic_predict_initialize.cpp.o" "/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict/tflite_semantic_predict_initialize.cpp"
make: Leaving directory ‘/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict’
make: Entering directory ‘/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict’
g++ -c -MMD -MP -MF"invokeinterpreter.cpp.dep" -MT"invokeinterpreter.cpp.o" -fpermissive -O2 -DMW_NUM_CORES=4 -pthread -fopenmp -std=c++17 -D__MW_TARGET_USE_HARDWARE_RESOURCES_H__ -D__linux__ -DARM_PROJECT -D_USE_TARGET_UDP_ -D_RUNONTARGETHARDWARE_BUILD_ -DSTACK_SIZE=200000 -DMODEL=tflite_semantic_predict -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/tflite_interface/invokeinterpreter/export/include/invokeinterpreter -I -I/tensorflow/lite -I/tensorflow/lite/tools/make/downloads/flatbuffers/include -I/flatbuffers/include -I/home/bmblaylock42/MATLAB_ws/R2024a/C/ProgramData/MATLAB/SupportPackages/R2024a/toolbox/realtime/targets/raspi/include -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/coder/rtiostream/src/utils -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/extern/include -o "invokeinterpreter.cpp.o" "/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/tflite_interface/invokeinterpreter/invokeinterpreter.cpp"
make: Leaving directory ‘/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict’
make: Entering directory ‘/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict’
g++ -c -MMD -MP -MF"tflite_semantic_predict.cpp.dep" -MT"tflite_semantic_predict.cpp.o" -fpermissive -O2 -DMW_NUM_CORES=4 -pthread -fopenmp -std=c++17 -D__MW_TARGET_USE_HARDWARE_RESOURCES_H__ -D__linux__ -DARM_PROJECT -D_USE_TARGET_UDP_ -D_RUNONTARGETHARDWARE_BUILD_ -DSTACK_SIZE=200000 -DMODEL=tflite_semantic_predict -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/tflite_interface/invokeinterpreter/export/include/invokeinterpreter -I -I/tensorflow/lite -I/tensorflow/lite/tools/make/downloads/flatbuffers/include -I/flatbuffers/include -I/home/bmblaylock42/MATLAB_ws/R2024a/C/ProgramData/MATLAB/SupportPackages/R2024a/toolbox/realtime/targets/raspi/include -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/coder/rtiostream/src/utils -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/extern/include -o "tflite_semantic_predict.cpp.o" "/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict/tflite_semantic_predict.cpp"
make: Leaving directory ‘/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict’
————————————————————————
Build error: C++ compiler produced errors. See the Build Log for further details.
More information
Code generation failed: View Error Report
Error using codegen
Thank you so much i have tried to download the flatbuffers by CMake and bazel but i had no luck since they are 64 bit codes and mine is a 32bit aarch64. tensorflow, matlab, code generation MATLAB Answers — New Questions
why is my loop printing 0 instead of a value, not sure which part of the code is incorrect
right now the code is at an increment of 15 to test, but the final incremment will be 0.01
code needs to have an if statement within the while loop.
%range is the maximum achievable horizontal distance
% range angle is the angle that yields the maximum horizontaal distance
% use a whilel loop with a nested if statement to compute the maximum
% landing distance (range) ange the angle corrsesponding to the maximum
% landing distance (rangle angle) of the ME En 1010 ping pong cannon
function [range, rangeAngle] = ProjectileRange(d1, d2, v0)
thetaL = 90;
range = 0;
rangeAngle = 0;
[xLand] = LandingDistance(d1, d2, v0, thetaL);
while thetaL <= 90;
if xLand > range
range = xLand
rangeAngle = thetaL
end
thetaL = thetaL + 15;
end
end
%% test
d1 = 0.0876;
d2 = 0.1190;
v0 = 3.2;
[range, rangeAngle] = ProjectileRange(d1, d2, v0);
fprintf(‘The range is %.2f m at a launch angle of %.2f degrees’, range, rangeAngle)
this is what it prints:
The range is 0.00 m at a launch angle of 0.00 degrees>>
I need it to print "the range is 1.29 m at a launch angle of 41.6 degrees" when it has an incrememnt of 0.01right now the code is at an increment of 15 to test, but the final incremment will be 0.01
code needs to have an if statement within the while loop.
%range is the maximum achievable horizontal distance
% range angle is the angle that yields the maximum horizontaal distance
% use a whilel loop with a nested if statement to compute the maximum
% landing distance (range) ange the angle corrsesponding to the maximum
% landing distance (rangle angle) of the ME En 1010 ping pong cannon
function [range, rangeAngle] = ProjectileRange(d1, d2, v0)
thetaL = 90;
range = 0;
rangeAngle = 0;
[xLand] = LandingDistance(d1, d2, v0, thetaL);
while thetaL <= 90;
if xLand > range
range = xLand
rangeAngle = thetaL
end
thetaL = thetaL + 15;
end
end
%% test
d1 = 0.0876;
d2 = 0.1190;
v0 = 3.2;
[range, rangeAngle] = ProjectileRange(d1, d2, v0);
fprintf(‘The range is %.2f m at a launch angle of %.2f degrees’, range, rangeAngle)
this is what it prints:
The range is 0.00 m at a launch angle of 0.00 degrees>>
I need it to print "the range is 1.29 m at a launch angle of 41.6 degrees" when it has an incrememnt of 0.01 right now the code is at an increment of 15 to test, but the final incremment will be 0.01
code needs to have an if statement within the while loop.
%range is the maximum achievable horizontal distance
% range angle is the angle that yields the maximum horizontaal distance
% use a whilel loop with a nested if statement to compute the maximum
% landing distance (range) ange the angle corrsesponding to the maximum
% landing distance (rangle angle) of the ME En 1010 ping pong cannon
function [range, rangeAngle] = ProjectileRange(d1, d2, v0)
thetaL = 90;
range = 0;
rangeAngle = 0;
[xLand] = LandingDistance(d1, d2, v0, thetaL);
while thetaL <= 90;
if xLand > range
range = xLand
rangeAngle = thetaL
end
thetaL = thetaL + 15;
end
end
%% test
d1 = 0.0876;
d2 = 0.1190;
v0 = 3.2;
[range, rangeAngle] = ProjectileRange(d1, d2, v0);
fprintf(‘The range is %.2f m at a launch angle of %.2f degrees’, range, rangeAngle)
this is what it prints:
The range is 0.00 m at a launch angle of 0.00 degrees>>
I need it to print "the range is 1.29 m at a launch angle of 41.6 degrees" when it has an incrememnt of 0.01 while/if loop, answer is 0 when it should be a value MATLAB Answers — New Questions