Category: Matlab
Category Archives: Matlab
Cannot echo Topics from Simulink in ROS on WSL2
I’m troubling in connecting Simulink and Unreal Engine through ROS on WSL2.
I want to send some messages from Simulink to UE (ROS Integration) using ROS Topics, but the topics from Simulink cannot be subscribed. (Actually the topic itself is subscribed, but no message is coming.)
My environment is as follows:
MATLAB R2024a + ROS Toolbox
Unreal Engine 5.1.1 (+ ROS Integration)
Ubuntu 20.04 on WSL2
ROS Noetic
I have confirmed the ROS communications below:
Simulink to the same Simulink: succes
Simulink to the other Simulink on the same computer: partly success (✔A→B, while ✘B→A. I suspected that the same port cannot be used for both publishing and subscribing, but alternating their roles did not work.)
Simulink to ROS: failed (The topics can be found by rostopic list, but I couldn’t rostopic echo.)
Simulink to UE: failed
UE to ROS: success (only String messages)
UE to Simulink: success (only String messages)
Regarding to the rostopic list, the rosnode info /SimulinkSystem_xxxxx (the node created by Simulink) response says that the connection to the node is failed.
I searched for the similar issues on internet and it may be caused by that the hostname cannot be resolved by ROS.
I have tried to set the environment variables so that they are not "localhost" nor "127.0.0.1", but it did not work. (When doing it, I could not connect to the ROS master.)
Could anyone figure out what is the true problem(s), and how to solve it?
Thank youI’m troubling in connecting Simulink and Unreal Engine through ROS on WSL2.
I want to send some messages from Simulink to UE (ROS Integration) using ROS Topics, but the topics from Simulink cannot be subscribed. (Actually the topic itself is subscribed, but no message is coming.)
My environment is as follows:
MATLAB R2024a + ROS Toolbox
Unreal Engine 5.1.1 (+ ROS Integration)
Ubuntu 20.04 on WSL2
ROS Noetic
I have confirmed the ROS communications below:
Simulink to the same Simulink: succes
Simulink to the other Simulink on the same computer: partly success (✔A→B, while ✘B→A. I suspected that the same port cannot be used for both publishing and subscribing, but alternating their roles did not work.)
Simulink to ROS: failed (The topics can be found by rostopic list, but I couldn’t rostopic echo.)
Simulink to UE: failed
UE to ROS: success (only String messages)
UE to Simulink: success (only String messages)
Regarding to the rostopic list, the rosnode info /SimulinkSystem_xxxxx (the node created by Simulink) response says that the connection to the node is failed.
I searched for the similar issues on internet and it may be caused by that the hostname cannot be resolved by ROS.
I have tried to set the environment variables so that they are not "localhost" nor "127.0.0.1", but it did not work. (When doing it, I could not connect to the ROS master.)
Could anyone figure out what is the true problem(s), and how to solve it?
Thank you I’m troubling in connecting Simulink and Unreal Engine through ROS on WSL2.
I want to send some messages from Simulink to UE (ROS Integration) using ROS Topics, but the topics from Simulink cannot be subscribed. (Actually the topic itself is subscribed, but no message is coming.)
My environment is as follows:
MATLAB R2024a + ROS Toolbox
Unreal Engine 5.1.1 (+ ROS Integration)
Ubuntu 20.04 on WSL2
ROS Noetic
I have confirmed the ROS communications below:
Simulink to the same Simulink: succes
Simulink to the other Simulink on the same computer: partly success (✔A→B, while ✘B→A. I suspected that the same port cannot be used for both publishing and subscribing, but alternating their roles did not work.)
Simulink to ROS: failed (The topics can be found by rostopic list, but I couldn’t rostopic echo.)
Simulink to UE: failed
UE to ROS: success (only String messages)
UE to Simulink: success (only String messages)
Regarding to the rostopic list, the rosnode info /SimulinkSystem_xxxxx (the node created by Simulink) response says that the connection to the node is failed.
I searched for the similar issues on internet and it may be caused by that the hostname cannot be resolved by ROS.
I have tried to set the environment variables so that they are not "localhost" nor "127.0.0.1", but it did not work. (When doing it, I could not connect to the ROS master.)
Could anyone figure out what is the true problem(s), and how to solve it?
Thank you matlab, simulink, ros, wsl2, noetic MATLAB Answers — New Questions
solving nonlinear wave equation
I need to solve this PDE below.
This is quite similar to the Burgers’ equation. However, I can’t understand how to get the exact solution to this equation. Please give an explicit solution to a given initial condition. Any initial condition is fine, just as long as the explicit solution is given. I will use it to check if my FDM code is correct.
In addition, if anyone has the code to solving this equation numerically, please post it here.
Thanks in advance!
below is my code.
for i = 2:(step(1)+1) % t
for j = 2:(step(2)+1) % x
rho(i, j) = rho(i-1, j) – v_max*(1-2*(rho(i-1, j)/rho_max))*(dt/dx)*(rho(i-1, j) – rho(i-1, j-1));
end
end
%———– set up —————
tspan = [0, 3]; % t
xspan = [-10, 10]; % x
step = [1000, 1000]; % step(1) : t, step(2) : x
t_values = linspace(tspan(1), tspan(2), step(1)+1);
x_values = linspace(xspan(1), xspan(2), step(2)+1);
v_max = 5; rho_max = 5; % vmax, rhomax
dt = (tspan(2) – tspan(1)) / step(1);
dx = (xspan(2) – xspan(1)) / step(2);
rho = zeros(step(1)+1, step(2)+1);
rhoo = zeros(step(1)+1, step(2)+1);
for j = 1:(step(1)+1)
rho(1, j) = 1/(1 + exp(j*dt));
end
%————- (FDM) ————-
for i = 2:(step(1)+1) % t
for j = 2:(step(2)+1) % x
rho(i, j) = rho(i-1, j) – v_max*(1-2*(rho(i-1, j)/rho_max))*(dt/dx)*(rho(i-1, j) – rho(i-1, j-1));
end
end
% for i = 1:(step(1)+1)
% for j = 1:(step(2)+1)
% rhoo(i, j) =
% end
% end
%———— animation ————–
filename = ‘animation.gif’;
figure;
for i = 1:(step(1)+1)
plot(x_values, rho(i, :));
xlabel(‘Position’);
ylabel(‘Density’);
title([‘Time = ‘, num2str(t_values(i))]);
drawnow;
frame = getframe(gcf);
img = frame2im(frame);
[imind, cm] = rgb2ind(img, 256);
if i == 1
imwrite(imind, cm, filename, ‘gif’, ‘Loopcount’, inf, ‘DelayTime’, dt);
else
imwrite(imind, cm, filename, ‘gif’, ‘WriteMode’, ‘append’, ‘DelayTime’, dt);
end
endI need to solve this PDE below.
This is quite similar to the Burgers’ equation. However, I can’t understand how to get the exact solution to this equation. Please give an explicit solution to a given initial condition. Any initial condition is fine, just as long as the explicit solution is given. I will use it to check if my FDM code is correct.
In addition, if anyone has the code to solving this equation numerically, please post it here.
Thanks in advance!
below is my code.
for i = 2:(step(1)+1) % t
for j = 2:(step(2)+1) % x
rho(i, j) = rho(i-1, j) – v_max*(1-2*(rho(i-1, j)/rho_max))*(dt/dx)*(rho(i-1, j) – rho(i-1, j-1));
end
end
%———– set up —————
tspan = [0, 3]; % t
xspan = [-10, 10]; % x
step = [1000, 1000]; % step(1) : t, step(2) : x
t_values = linspace(tspan(1), tspan(2), step(1)+1);
x_values = linspace(xspan(1), xspan(2), step(2)+1);
v_max = 5; rho_max = 5; % vmax, rhomax
dt = (tspan(2) – tspan(1)) / step(1);
dx = (xspan(2) – xspan(1)) / step(2);
rho = zeros(step(1)+1, step(2)+1);
rhoo = zeros(step(1)+1, step(2)+1);
for j = 1:(step(1)+1)
rho(1, j) = 1/(1 + exp(j*dt));
end
%————- (FDM) ————-
for i = 2:(step(1)+1) % t
for j = 2:(step(2)+1) % x
rho(i, j) = rho(i-1, j) – v_max*(1-2*(rho(i-1, j)/rho_max))*(dt/dx)*(rho(i-1, j) – rho(i-1, j-1));
end
end
% for i = 1:(step(1)+1)
% for j = 1:(step(2)+1)
% rhoo(i, j) =
% end
% end
%———— animation ————–
filename = ‘animation.gif’;
figure;
for i = 1:(step(1)+1)
plot(x_values, rho(i, :));
xlabel(‘Position’);
ylabel(‘Density’);
title([‘Time = ‘, num2str(t_values(i))]);
drawnow;
frame = getframe(gcf);
img = frame2im(frame);
[imind, cm] = rgb2ind(img, 256);
if i == 1
imwrite(imind, cm, filename, ‘gif’, ‘Loopcount’, inf, ‘DelayTime’, dt);
else
imwrite(imind, cm, filename, ‘gif’, ‘WriteMode’, ‘append’, ‘DelayTime’, dt);
end
end I need to solve this PDE below.
This is quite similar to the Burgers’ equation. However, I can’t understand how to get the exact solution to this equation. Please give an explicit solution to a given initial condition. Any initial condition is fine, just as long as the explicit solution is given. I will use it to check if my FDM code is correct.
In addition, if anyone has the code to solving this equation numerically, please post it here.
Thanks in advance!
below is my code.
for i = 2:(step(1)+1) % t
for j = 2:(step(2)+1) % x
rho(i, j) = rho(i-1, j) – v_max*(1-2*(rho(i-1, j)/rho_max))*(dt/dx)*(rho(i-1, j) – rho(i-1, j-1));
end
end
%———– set up —————
tspan = [0, 3]; % t
xspan = [-10, 10]; % x
step = [1000, 1000]; % step(1) : t, step(2) : x
t_values = linspace(tspan(1), tspan(2), step(1)+1);
x_values = linspace(xspan(1), xspan(2), step(2)+1);
v_max = 5; rho_max = 5; % vmax, rhomax
dt = (tspan(2) – tspan(1)) / step(1);
dx = (xspan(2) – xspan(1)) / step(2);
rho = zeros(step(1)+1, step(2)+1);
rhoo = zeros(step(1)+1, step(2)+1);
for j = 1:(step(1)+1)
rho(1, j) = 1/(1 + exp(j*dt));
end
%————- (FDM) ————-
for i = 2:(step(1)+1) % t
for j = 2:(step(2)+1) % x
rho(i, j) = rho(i-1, j) – v_max*(1-2*(rho(i-1, j)/rho_max))*(dt/dx)*(rho(i-1, j) – rho(i-1, j-1));
end
end
% for i = 1:(step(1)+1)
% for j = 1:(step(2)+1)
% rhoo(i, j) =
% end
% end
%———— animation ————–
filename = ‘animation.gif’;
figure;
for i = 1:(step(1)+1)
plot(x_values, rho(i, :));
xlabel(‘Position’);
ylabel(‘Density’);
title([‘Time = ‘, num2str(t_values(i))]);
drawnow;
frame = getframe(gcf);
img = frame2im(frame);
[imind, cm] = rgb2ind(img, 256);
if i == 1
imwrite(imind, cm, filename, ‘gif’, ‘Loopcount’, inf, ‘DelayTime’, dt);
else
imwrite(imind, cm, filename, ‘gif’, ‘WriteMode’, ‘append’, ‘DelayTime’, dt);
end
end pde MATLAB Answers — New Questions
how to Create random signal
random signal how torandom signal how to random signal how to MATLAB Answers — New Questions
USRP X310 HDL coder
Does HDL Coder support USRP X310?Does HDL Coder support USRP X310? Does HDL Coder support USRP X310? x310, hdl coder, usrp MATLAB Answers — New Questions
Multi-thread parsing and loading thousands of csv files
I have a folder with 2500 csv files, each 15MB each. I currently have a script that reads each csv into a cell array container as follows at the bottom.
Unfortunately this serial process takes a very long time to open each csv one by one.
Ideally I would like to multi-thread or open multiple csv files in parallel and save them into either their own set of cell arrays per ‘thread’ and later combine and sort them, or into one big cell array as it is currently.
%% IMPORT FILES
directory = ‘\headnodeuserdataGeorgeANSTOANSTO Day 2DataD14’;
datafiles = dir(append(directory,’*.csv’));
N=length(datafiles);
a = 0;
data = cell(1,N);
f = waitbar(a,’Importing Data…’);
for i = 1:N
data{i} = read_csv(strcat(datafiles(i).folder, ”, datafiles(i).name));
waitbar(i/N,f);
end
waitbar(1,f);
close(f);I have a folder with 2500 csv files, each 15MB each. I currently have a script that reads each csv into a cell array container as follows at the bottom.
Unfortunately this serial process takes a very long time to open each csv one by one.
Ideally I would like to multi-thread or open multiple csv files in parallel and save them into either their own set of cell arrays per ‘thread’ and later combine and sort them, or into one big cell array as it is currently.
%% IMPORT FILES
directory = ‘\headnodeuserdataGeorgeANSTOANSTO Day 2DataD14’;
datafiles = dir(append(directory,’*.csv’));
N=length(datafiles);
a = 0;
data = cell(1,N);
f = waitbar(a,’Importing Data…’);
for i = 1:N
data{i} = read_csv(strcat(datafiles(i).folder, ”, datafiles(i).name));
waitbar(i/N,f);
end
waitbar(1,f);
close(f); I have a folder with 2500 csv files, each 15MB each. I currently have a script that reads each csv into a cell array container as follows at the bottom.
Unfortunately this serial process takes a very long time to open each csv one by one.
Ideally I would like to multi-thread or open multiple csv files in parallel and save them into either their own set of cell arrays per ‘thread’ and later combine and sort them, or into one big cell array as it is currently.
%% IMPORT FILES
directory = ‘\headnodeuserdataGeorgeANSTOANSTO Day 2DataD14’;
datafiles = dir(append(directory,’*.csv’));
N=length(datafiles);
a = 0;
data = cell(1,N);
f = waitbar(a,’Importing Data…’);
for i = 1:N
data{i} = read_csv(strcat(datafiles(i).folder, ”, datafiles(i).name));
waitbar(i/N,f);
end
waitbar(1,f);
close(f); multi-thread, csv, file, file processing, speed, file handling, file import, data import, multiple, parsing, parallel, parallel computing MATLAB Answers — New Questions
Missing pulse with variable phase shift and configuring action qualifier
Hello,
I am using simulink to program c2000 TMS320F28379D microcontroller to test a dc-ac converter. I have a variable phase-shift input to the epwm. My TBPRD is 330 and the phase shift counter value can vary from -165 to 165 for up count mode. I am having issue with missing pulses near zero crossing. I posted this question on TI forum and got a suggestion to implement a trigger to check if TBCTR is less than CMPA and the TBPHS value is greater than CMPA. Below is the link for the link for the question I asked and the response. I see that there is a way to specify software synchronization through input port. However, I am not sure how to configure TBCTR and input the suggested logic in simulink.
The suggested logic is toselect EPWMxSYNC as the T1 event source and then set the action taken on T1-up to be setting the EPWM2A high. In this way, the action from a T1-up event would supplement what the missing CMPA(up) = 1000 action would have done.
Keep in mind that when these conditions are not true, the T1-up/down events need to be disabled to prevent it from affecting your desired duty cycle. Let me know if you have further questions here or have made any other progress.
How can I implement this logic in the epwm to handle these missing pulses?
Question I posted on TI forum
https://e2e.ti.com/support/microcontrollers/c2000-microcontrollers-group/c2000/f/c2000-microcontrollers-forum/1372906/tms320f28379d-tms320f28379d-missing-pulses-with-variable-phase-shift
TI forum response
https://e2e.ti.com/support/microcontrollers/c2000-microcontrollers-group/c2000/f/c2000-microcontrollers-forum/1312604/tms320f28379d-tms320f28379d-phase-shift-pwm-missing-pulse
I have also attached the simulink file. Would it be possible to check if my epwm configurations are correct? I have a missing pulse near the zero crossing of ac line voltage since a sharp phase shift transition happens there.
Thank you in advance.Hello,
I am using simulink to program c2000 TMS320F28379D microcontroller to test a dc-ac converter. I have a variable phase-shift input to the epwm. My TBPRD is 330 and the phase shift counter value can vary from -165 to 165 for up count mode. I am having issue with missing pulses near zero crossing. I posted this question on TI forum and got a suggestion to implement a trigger to check if TBCTR is less than CMPA and the TBPHS value is greater than CMPA. Below is the link for the link for the question I asked and the response. I see that there is a way to specify software synchronization through input port. However, I am not sure how to configure TBCTR and input the suggested logic in simulink.
The suggested logic is toselect EPWMxSYNC as the T1 event source and then set the action taken on T1-up to be setting the EPWM2A high. In this way, the action from a T1-up event would supplement what the missing CMPA(up) = 1000 action would have done.
Keep in mind that when these conditions are not true, the T1-up/down events need to be disabled to prevent it from affecting your desired duty cycle. Let me know if you have further questions here or have made any other progress.
How can I implement this logic in the epwm to handle these missing pulses?
Question I posted on TI forum
https://e2e.ti.com/support/microcontrollers/c2000-microcontrollers-group/c2000/f/c2000-microcontrollers-forum/1372906/tms320f28379d-tms320f28379d-missing-pulses-with-variable-phase-shift
TI forum response
https://e2e.ti.com/support/microcontrollers/c2000-microcontrollers-group/c2000/f/c2000-microcontrollers-forum/1312604/tms320f28379d-tms320f28379d-phase-shift-pwm-missing-pulse
I have also attached the simulink file. Would it be possible to check if my epwm configurations are correct? I have a missing pulse near the zero crossing of ac line voltage since a sharp phase shift transition happens there.
Thank you in advance. Hello,
I am using simulink to program c2000 TMS320F28379D microcontroller to test a dc-ac converter. I have a variable phase-shift input to the epwm. My TBPRD is 330 and the phase shift counter value can vary from -165 to 165 for up count mode. I am having issue with missing pulses near zero crossing. I posted this question on TI forum and got a suggestion to implement a trigger to check if TBCTR is less than CMPA and the TBPHS value is greater than CMPA. Below is the link for the link for the question I asked and the response. I see that there is a way to specify software synchronization through input port. However, I am not sure how to configure TBCTR and input the suggested logic in simulink.
The suggested logic is toselect EPWMxSYNC as the T1 event source and then set the action taken on T1-up to be setting the EPWM2A high. In this way, the action from a T1-up event would supplement what the missing CMPA(up) = 1000 action would have done.
Keep in mind that when these conditions are not true, the T1-up/down events need to be disabled to prevent it from affecting your desired duty cycle. Let me know if you have further questions here or have made any other progress.
How can I implement this logic in the epwm to handle these missing pulses?
Question I posted on TI forum
https://e2e.ti.com/support/microcontrollers/c2000-microcontrollers-group/c2000/f/c2000-microcontrollers-forum/1372906/tms320f28379d-tms320f28379d-missing-pulses-with-variable-phase-shift
TI forum response
https://e2e.ti.com/support/microcontrollers/c2000-microcontrollers-group/c2000/f/c2000-microcontrollers-forum/1312604/tms320f28379d-tms320f28379d-phase-shift-pwm-missing-pulse
I have also attached the simulink file. Would it be possible to check if my epwm configurations are correct? I have a missing pulse near the zero crossing of ac line voltage since a sharp phase shift transition happens there.
Thank you in advance. missing pulse, trigger MATLAB Answers — New Questions
ROS2, MATLAB, GAZEBO.
I’m using ros2/Matlab and need the tranformations in a chart. How could I do that.I’m using ros2/Matlab and need the tranformations in a chart. How could I do that. I’m using ros2/Matlab and need the tranformations in a chart. How could I do that. ros2 MATLAB Answers — New Questions
Confidence interval calculation. Cannot compute confidence interval for imaginary values.
clear; clc
load Steady_State_Data.mat % this contains the wavelength of light and absorbance of substrate and sample
%% Preamble
% Fundamental constants
h = 4.0135667696*10^-15; % units: eV/ Hz
c = 3*10^8; % SI units
% Clean up of data to select range of values
Absorbance = log10(T_substrate./T_sample);
E = (h*c./(Lambda*10^-9));
e = E >= 0 & E <= 2.0; % returns boolean value of the indices that satisfies the logical condition defined above
A = find(e); % gives indices that are non-zero
N = length(A); % no. of elements that are non-zero
n = length(E) + 1;
% Data for fitting
E_p = E(n-N:167);
Abs = Absorbance(n-N:167) – min(Absorbance);
% Abs = Absorbance(n-N:167);
% Fitting function
function F = EM_SS(p, e_p)
for i = 1:numel(e_p)
E_p = e_p(i);
F(i) = p(1)*(2*pi*sqrt(p(4))/E_p)*(1/p(6))*…
(integral(@(E)sech(((E_p – E)./p(6)))*(1 + 10*p(5)*(E – p(3)) + …
126*(p(5))^2*(E – p(3))^2)/(1 – exp(-2*pi*sqrt(p(4)/(E – p(3))))), p(3), Inf, ‘ArrayValued’, 1)) + …
p(2)*(2*pi*p(4)^3/2)*1/p(6)*(…
(1/1^3)*sech((E_p – p(3) + p(4)/1^2)./p(6)) + …
(1/2^3)*sech((E_p – p(3) + p(4)/2^2)./p(6)) + …
(1/3^3)*sech((E_p – p(3) + p(4)/3^2)./p(6)) + …
(1/4^3)*sech((E_p – p(3) + p(4)/4^2)./p(6)) + …
(1/5^3)*sech((E_p – p(3) + p(4)/5^2)./p(6)) + …
(1/6^3)*sech((E_p – p(3) + p(4)/6^2)./p(6)) + …
(1/7^3)*sech((E_p – p(3) + p(4)/7^2)./p(6)));
end
F = F(:);
end
%% Curve fitting options
% Initial parameter guess and bounds
lb = [0,0,0,0,0,0]; ub = [Inf, Inf, 1.65, 0.03, Inf, Inf];
p0 = [0.13, 0.11, 1.4, 0.025, 0.12, 0.035]; % refer to the next line for their order
% p0 = [A1, A2, Eg, Eb, R, g]
% lsqcurvefit and choose between different algorithm that lsqcurvefit employs (3C1, comment those lines that are not choosen and uncomment the line that is choosen, if not, matlab will take the last line of "optim_lsq" by default)
optim_lsq = optimoptions(‘lsqcurvefit’, ‘Algorithm’, ‘levenberg-marquardt’, ‘MaxFunctionEvaluations’,1000, ‘MaxIterations’, 1000, ‘FunctionTolerance’,10^-9, ‘StepTolerance’, 10^-9);
% optim_lsq = optimoptions(‘lsqcurvefit’, ‘Algorithm’, ‘trust-region-reflective’, ‘MaxFunctionEvaluations’,1000, ‘MaxIterations’, ‘FunctionTolerance’,10^-9, ‘StepTolerance’, 10^-9);
% optim_lsq = optimoptions(‘lsqcurvefit’, ‘Algorithm’, ‘interior-point’, ‘MaxFunctionEvaluations’,1000, ‘MaxIterations’, 1000, ‘FunctionTolerance’,10^-9, ‘StepTolerance’, 10^-9);
% Solver for lsqcurvefit
[p, residual, exitflag, output, jacobian] = lsqcurvefit(@EM_SS, p0, E_p, Abs, lb, ub);
%% Standard error calculation
ci = nlparci(p, residual, ‘Jacobian’, jacobian);
lowerbar = p – ci(:,1);
uppperbar = ci(:,2) – p;
if p == real(p)
disp(‘Real’)
else
disp(‘Complex with non-zero imaginary’)
end
if residual == real(residual)
disp(‘Real’)
else
disp(‘Complex with non-zero imaginary’)
end
if J == real(J)
disp(‘Real’)
else
disp(‘Complex with non-zero imaginary’)
end
%% Plot command
plot(E_p, Abs, ‘o’)
hold on
plot(E_p, EM_SS(p, E_p))
xlabel(‘Probe energy (eV)’)
ylabel(‘Absorbance.O.D’)
legend(‘Experimental Data’, ‘Fitted Curve’)
hold off
%% Parameter values (refer to command window)
p1 = p(1,1);
p2 = p(1,2);
p3 = p(1,3);
p4 = p(1,4);
p5 = p(1,5);
p6 = p(1,6);
X1 = [‘ A1 = ‘, num2str(p1)];
X2 = [‘ A2 = ‘, num2str(p2)];
X3 = [‘ Eg = ‘, num2str(p3)];
X4 = [‘ Eb = ‘, num2str(p4)];
X5 = [‘ R = ‘, num2str(p5)];
X6 = [‘ g = ‘, num2str(p6)];
disp(X1);
disp(X2);
disp(X3);
disp(X4);
disp(X5);
disp(X6);
Hi all, I am doing a fitting to my experimental data and I am now trying to calculate the confidence interval. However, it seems like there is something wrong with my code and the computer can’t really calculate it. May I ask where I am wrong? I tried following the instructions on this link but I still can’t get any results.clear; clc
load Steady_State_Data.mat % this contains the wavelength of light and absorbance of substrate and sample
%% Preamble
% Fundamental constants
h = 4.0135667696*10^-15; % units: eV/ Hz
c = 3*10^8; % SI units
% Clean up of data to select range of values
Absorbance = log10(T_substrate./T_sample);
E = (h*c./(Lambda*10^-9));
e = E >= 0 & E <= 2.0; % returns boolean value of the indices that satisfies the logical condition defined above
A = find(e); % gives indices that are non-zero
N = length(A); % no. of elements that are non-zero
n = length(E) + 1;
% Data for fitting
E_p = E(n-N:167);
Abs = Absorbance(n-N:167) – min(Absorbance);
% Abs = Absorbance(n-N:167);
% Fitting function
function F = EM_SS(p, e_p)
for i = 1:numel(e_p)
E_p = e_p(i);
F(i) = p(1)*(2*pi*sqrt(p(4))/E_p)*(1/p(6))*…
(integral(@(E)sech(((E_p – E)./p(6)))*(1 + 10*p(5)*(E – p(3)) + …
126*(p(5))^2*(E – p(3))^2)/(1 – exp(-2*pi*sqrt(p(4)/(E – p(3))))), p(3), Inf, ‘ArrayValued’, 1)) + …
p(2)*(2*pi*p(4)^3/2)*1/p(6)*(…
(1/1^3)*sech((E_p – p(3) + p(4)/1^2)./p(6)) + …
(1/2^3)*sech((E_p – p(3) + p(4)/2^2)./p(6)) + …
(1/3^3)*sech((E_p – p(3) + p(4)/3^2)./p(6)) + …
(1/4^3)*sech((E_p – p(3) + p(4)/4^2)./p(6)) + …
(1/5^3)*sech((E_p – p(3) + p(4)/5^2)./p(6)) + …
(1/6^3)*sech((E_p – p(3) + p(4)/6^2)./p(6)) + …
(1/7^3)*sech((E_p – p(3) + p(4)/7^2)./p(6)));
end
F = F(:);
end
%% Curve fitting options
% Initial parameter guess and bounds
lb = [0,0,0,0,0,0]; ub = [Inf, Inf, 1.65, 0.03, Inf, Inf];
p0 = [0.13, 0.11, 1.4, 0.025, 0.12, 0.035]; % refer to the next line for their order
% p0 = [A1, A2, Eg, Eb, R, g]
% lsqcurvefit and choose between different algorithm that lsqcurvefit employs (3C1, comment those lines that are not choosen and uncomment the line that is choosen, if not, matlab will take the last line of "optim_lsq" by default)
optim_lsq = optimoptions(‘lsqcurvefit’, ‘Algorithm’, ‘levenberg-marquardt’, ‘MaxFunctionEvaluations’,1000, ‘MaxIterations’, 1000, ‘FunctionTolerance’,10^-9, ‘StepTolerance’, 10^-9);
% optim_lsq = optimoptions(‘lsqcurvefit’, ‘Algorithm’, ‘trust-region-reflective’, ‘MaxFunctionEvaluations’,1000, ‘MaxIterations’, ‘FunctionTolerance’,10^-9, ‘StepTolerance’, 10^-9);
% optim_lsq = optimoptions(‘lsqcurvefit’, ‘Algorithm’, ‘interior-point’, ‘MaxFunctionEvaluations’,1000, ‘MaxIterations’, 1000, ‘FunctionTolerance’,10^-9, ‘StepTolerance’, 10^-9);
% Solver for lsqcurvefit
[p, residual, exitflag, output, jacobian] = lsqcurvefit(@EM_SS, p0, E_p, Abs, lb, ub);
%% Standard error calculation
ci = nlparci(p, residual, ‘Jacobian’, jacobian);
lowerbar = p – ci(:,1);
uppperbar = ci(:,2) – p;
if p == real(p)
disp(‘Real’)
else
disp(‘Complex with non-zero imaginary’)
end
if residual == real(residual)
disp(‘Real’)
else
disp(‘Complex with non-zero imaginary’)
end
if J == real(J)
disp(‘Real’)
else
disp(‘Complex with non-zero imaginary’)
end
%% Plot command
plot(E_p, Abs, ‘o’)
hold on
plot(E_p, EM_SS(p, E_p))
xlabel(‘Probe energy (eV)’)
ylabel(‘Absorbance.O.D’)
legend(‘Experimental Data’, ‘Fitted Curve’)
hold off
%% Parameter values (refer to command window)
p1 = p(1,1);
p2 = p(1,2);
p3 = p(1,3);
p4 = p(1,4);
p5 = p(1,5);
p6 = p(1,6);
X1 = [‘ A1 = ‘, num2str(p1)];
X2 = [‘ A2 = ‘, num2str(p2)];
X3 = [‘ Eg = ‘, num2str(p3)];
X4 = [‘ Eb = ‘, num2str(p4)];
X5 = [‘ R = ‘, num2str(p5)];
X6 = [‘ g = ‘, num2str(p6)];
disp(X1);
disp(X2);
disp(X3);
disp(X4);
disp(X5);
disp(X6);
Hi all, I am doing a fitting to my experimental data and I am now trying to calculate the confidence interval. However, it seems like there is something wrong with my code and the computer can’t really calculate it. May I ask where I am wrong? I tried following the instructions on this link but I still can’t get any results. clear; clc
load Steady_State_Data.mat % this contains the wavelength of light and absorbance of substrate and sample
%% Preamble
% Fundamental constants
h = 4.0135667696*10^-15; % units: eV/ Hz
c = 3*10^8; % SI units
% Clean up of data to select range of values
Absorbance = log10(T_substrate./T_sample);
E = (h*c./(Lambda*10^-9));
e = E >= 0 & E <= 2.0; % returns boolean value of the indices that satisfies the logical condition defined above
A = find(e); % gives indices that are non-zero
N = length(A); % no. of elements that are non-zero
n = length(E) + 1;
% Data for fitting
E_p = E(n-N:167);
Abs = Absorbance(n-N:167) – min(Absorbance);
% Abs = Absorbance(n-N:167);
% Fitting function
function F = EM_SS(p, e_p)
for i = 1:numel(e_p)
E_p = e_p(i);
F(i) = p(1)*(2*pi*sqrt(p(4))/E_p)*(1/p(6))*…
(integral(@(E)sech(((E_p – E)./p(6)))*(1 + 10*p(5)*(E – p(3)) + …
126*(p(5))^2*(E – p(3))^2)/(1 – exp(-2*pi*sqrt(p(4)/(E – p(3))))), p(3), Inf, ‘ArrayValued’, 1)) + …
p(2)*(2*pi*p(4)^3/2)*1/p(6)*(…
(1/1^3)*sech((E_p – p(3) + p(4)/1^2)./p(6)) + …
(1/2^3)*sech((E_p – p(3) + p(4)/2^2)./p(6)) + …
(1/3^3)*sech((E_p – p(3) + p(4)/3^2)./p(6)) + …
(1/4^3)*sech((E_p – p(3) + p(4)/4^2)./p(6)) + …
(1/5^3)*sech((E_p – p(3) + p(4)/5^2)./p(6)) + …
(1/6^3)*sech((E_p – p(3) + p(4)/6^2)./p(6)) + …
(1/7^3)*sech((E_p – p(3) + p(4)/7^2)./p(6)));
end
F = F(:);
end
%% Curve fitting options
% Initial parameter guess and bounds
lb = [0,0,0,0,0,0]; ub = [Inf, Inf, 1.65, 0.03, Inf, Inf];
p0 = [0.13, 0.11, 1.4, 0.025, 0.12, 0.035]; % refer to the next line for their order
% p0 = [A1, A2, Eg, Eb, R, g]
% lsqcurvefit and choose between different algorithm that lsqcurvefit employs (3C1, comment those lines that are not choosen and uncomment the line that is choosen, if not, matlab will take the last line of "optim_lsq" by default)
optim_lsq = optimoptions(‘lsqcurvefit’, ‘Algorithm’, ‘levenberg-marquardt’, ‘MaxFunctionEvaluations’,1000, ‘MaxIterations’, 1000, ‘FunctionTolerance’,10^-9, ‘StepTolerance’, 10^-9);
% optim_lsq = optimoptions(‘lsqcurvefit’, ‘Algorithm’, ‘trust-region-reflective’, ‘MaxFunctionEvaluations’,1000, ‘MaxIterations’, ‘FunctionTolerance’,10^-9, ‘StepTolerance’, 10^-9);
% optim_lsq = optimoptions(‘lsqcurvefit’, ‘Algorithm’, ‘interior-point’, ‘MaxFunctionEvaluations’,1000, ‘MaxIterations’, 1000, ‘FunctionTolerance’,10^-9, ‘StepTolerance’, 10^-9);
% Solver for lsqcurvefit
[p, residual, exitflag, output, jacobian] = lsqcurvefit(@EM_SS, p0, E_p, Abs, lb, ub);
%% Standard error calculation
ci = nlparci(p, residual, ‘Jacobian’, jacobian);
lowerbar = p – ci(:,1);
uppperbar = ci(:,2) – p;
if p == real(p)
disp(‘Real’)
else
disp(‘Complex with non-zero imaginary’)
end
if residual == real(residual)
disp(‘Real’)
else
disp(‘Complex with non-zero imaginary’)
end
if J == real(J)
disp(‘Real’)
else
disp(‘Complex with non-zero imaginary’)
end
%% Plot command
plot(E_p, Abs, ‘o’)
hold on
plot(E_p, EM_SS(p, E_p))
xlabel(‘Probe energy (eV)’)
ylabel(‘Absorbance.O.D’)
legend(‘Experimental Data’, ‘Fitted Curve’)
hold off
%% Parameter values (refer to command window)
p1 = p(1,1);
p2 = p(1,2);
p3 = p(1,3);
p4 = p(1,4);
p5 = p(1,5);
p6 = p(1,6);
X1 = [‘ A1 = ‘, num2str(p1)];
X2 = [‘ A2 = ‘, num2str(p2)];
X3 = [‘ Eg = ‘, num2str(p3)];
X4 = [‘ Eb = ‘, num2str(p4)];
X5 = [‘ R = ‘, num2str(p5)];
X6 = [‘ g = ‘, num2str(p6)];
disp(X1);
disp(X2);
disp(X3);
disp(X4);
disp(X5);
disp(X6);
Hi all, I am doing a fitting to my experimental data and I am now trying to calculate the confidence interval. However, it seems like there is something wrong with my code and the computer can’t really calculate it. May I ask where I am wrong? I tried following the instructions on this link but I still can’t get any results. confidence interval, error bars MATLAB Answers — New Questions
User equipment in Small cell Network!
How to define a user equipment in a picocell or anykind of cell?How to define a user equipment in a picocell or anykind of cell? How to define a user equipment in a picocell or anykind of cell? small cells, user equipment MATLAB Answers — New Questions
plot some nodes from an .txt file
Hi! I would like to hope if there is an easy way to plot only the outermost nodes (the red nodes in the figure).
I am leaving the filename.txt file representing the nodes.Hi! I would like to hope if there is an easy way to plot only the outermost nodes (the red nodes in the figure).
I am leaving the filename.txt file representing the nodes. Hi! I would like to hope if there is an easy way to plot only the outermost nodes (the red nodes in the figure).
I am leaving the filename.txt file representing the nodes. nodes, plot, plotting, txt, text file, file MATLAB Answers — New Questions
Why/How is Circshift so fast?
I have the following function in Matlab:
function [RawDataKK]=DataCompressKKTest(Data,RXangle,s)
tSize=size(Data,1);
xSize=size(Data,2);
TXSize=size(Data,3);
RXSize=numel(RXangle);
RawDataKK=zeros(tSize,TXSize,RXSize);
DataTemp=zeros(tSize,xSize);
slope = s*sin(RXangle(:))/2;
nShift = round(slope.*((0:xSize-1) – (xSize-1)*(1-sign(RXangle(:)))/2));
for nR=1:RXSize
for nT=1:TXSize
for nx=1:xSize
DataTemp(:,nx)=circshift(Data(:,nx,nT),nShift(nR,nx));
end
RawDataKK(:,nT,nR)=sum(DataTemp,2);
end
end
end
I tried implementing it as a C++ function using the Eigen toolbox and the Matlab Data API for C++. The basic logic of the C++ implementation uses a reindexing approach to implement circshift.
“` lang-cpp
#include <iostream>
#include "mex.hpp"
#include "mexAdapter.hpp"
#include <Eigen/Dense>
#include <MatlabDataArray.hpp>
#include <cmath>
#include <math.h>
#include <omp.h>
class MexFunction : public matlab::mex::Function {
public:
// Factory to create MATLAB data arrays
matlab::data::ArrayFactory factory;
void operator()(matlab::mex::ArgumentList outputs, matlab::mex::ArgumentList inputs) {
checkArguments(outputs, inputs);
// Initialize input parameters
int tSize = inputs[0][0];
int xSize = inputs[0][1];
int TXSize = inputs[0][2];
int RXSize = inputs[0][3];
int RFlen = inputs[0][4];
auto ptr = getDataPtr<std::complex<double>>(inputs[1]);
Eigen::Map< const Eigen::MatrixXcd > Data( ptr, RFlen, xSize );
double s = inputs[2][0];
auto ptr2 = getDataPtr<double>(inputs[3]);
Eigen::Map< const Eigen::VectorXd > RXangle( ptr2, RXSize );
auto ptr3 = getDataPtr<int32_t>(inputs[4]);
Eigen::Map< const Eigen::MatrixXi > indices( ptr3, tSize, xSize*RXSize );
outputs[0] = factory.createArray<std::complex<double>>({static_cast<size_t>(tSize),static_cast<size_t>(TXSize*RXSize)});
auto ptrRecon = getOutDataPtr<std::complex<double>>(outputs[0]);
Eigen::Map<Eigen::MatrixXcd> RFDataKK(ptrRecon,tSize,TXSize*RXSize);
// Get num threads
int numThreads = omp_get_max_threads();
int nProc = omp_get_num_procs();
omp_set_num_threads(nProc*2);
#pragma omp parallel for
for (int nR = 0; nR < RXSize; nR++) {
Eigen::MatrixXcd shiftedData = Eigen::MatrixXcd::Zero(tSize*TXSize,xSize);
for (int nT = 0; nT < TXSize; nT++){
extractData(shiftedData(Eigen::seq(nT*tSize,(nT+1)*tSize-1),Eigen::all),
Data(Eigen::seq(nT*tSize,(nT+1)*tSize-1),Eigen::all),
indices(Eigen::all,Eigen::seq(nR*xSize, (nR+1)*xSize-1)), xSize, tSize);
}
RFDataKK(Eigen::all,Eigen::seq(nR*TXSize,(nR+1)*TXSize-1) ) = shiftedData.rowwise().sum().reshaped(tSize,TXSize);
}
}
void extractData(Eigen::Ref<Eigen::MatrixXcd> shiftedData, const Eigen::Ref<const Eigen::MatrixXcd>& Data,
const Eigen::Ref<const Eigen::MatrixXi>& indices, const long int& xSize, const long int& tSize) {
for (int i = 0; i < tSize*xSize; i++) {
int nt = i % tSize;
int nx = i / tSize;
int row = indices(nt,nx) % tSize;
int col = indices(nt,nx) / tSize;
shiftedData(row,col) = Data(nt,nx);
}
}
void checkArguments(matlab::mex::ArgumentList outputs, matlab::mex::ArgumentList inputs) {
std::shared_ptr<matlab::engine::MATLABEngine> matlabPtr = getEngine();
matlab::data::ArrayFactory factory;
// TODO: Implement remaining checks
}
template <typename T>
const T* getDataPtr(matlab::data::Array arr) {
const matlab::data::TypedArray<T> arr_t = arr;
matlab::data::TypedIterator<const T> it(arr_t.begin());
return it.operator->();
}
template <typename T>
T* getOutDataPtr(matlab::data::Array& arr) {
auto range = matlab::data::getWritableElements<T>(arr);
return range.begin().operator->();
}
};
“`
Where I precompute the values of indices using the following Matlab function:
function linIndices=DataCompressKKIndices(RXangle,s,tSize,xSize,TXSize,RXSize)
shiftedData = zeros(tSize, xSize, TXSize);
RFDatKK = zeros(tSize,TXSize,RXSize);
RFDataKK = zeros(tSize,xSize*RXSize);
slope=s*sin(RXangle(:))/2;
nShift = round(slope.*((0:xSize-1) – (xSize-1)*(1-sign(RXangle(:)))/2));
indices = mod((0:tSize-1).’ + reshape(nShift.’,[],1).’,tSize);
linIndices = indices + repmat((0:xSize-1)*tSize,1,RXSize);
end
When I perform a speed test in Matlab after compiling with the following parameters (with mingw GCC version 8.3), I find that I have not gained a meaningful speedup for the array sizes I am working with. OpenMP parallelization should at least give me an order of magnitude speed up (I have 24 threads on my machine). There are two questions that yields:
1. Why is a reindexing approach slower than doing circshift? A reindexing approach in Matlab (not shown here) is almost 2x slower than using nested for loops and circshift.
2. What exactly could circshift be doing under the hood that is so efficient? Is there some funky pointer arithmetic that could accomplish the functionality of circshift?
Compilation and testing code:
%% Compilation
mingwFlags = {‘CXXFLAGS="$CXXFLAGS -march=native -std=c++14 -fno-math-errno -ffast-math -fopenmp -DNDEBUG -w -Wno-error"’,…
‘LDFLAGS="$LDFLAGS -fopenmp"’,’CXXOPTIMFLAGS="-O3"’};
% ipath is the path to the eigen library.
tic; mex(ipath,mingwFlags{1},mingwFlags{2},mingwFlags{3},’CompressKK.cpp’); toc
tic; mex(ipath,mingwFlags{1},mingwFlags{2},mingwFlags{3},’CompressKKIndices.cpp’); toc
%% Initialize some random data
…
% tSize = 2688, xSize = 192, TXSize = 15, RXSize = 16 for trial cases
%% Timing Test
nTrials = 100;
T = zeros(nTrials,4);
for i = 1:nTrials
tic; indices = DataCompressKKIndices(p.RXangle,s,double(p.szRFframe+1),double(p.numEl),p.na,p.nRX);
RawDataKK3 = CompressKKIndices(param,cRF(1:param(5),p.ConnMap),s,p.RXangle,int32(indices));
RawDataKK3 = reshape(RawDataKK3,[p.szRFframe+1,p.na,p.nRX]); T(i,1) = toc;
tic; RawDataKK=DataCompressKKTest(Data,p.RXangle,s); T(i,2) = toc;
end
chkT = mean(T,1)
Timing Results:
chkT =
C++ version: 0.4867 0.8299I have the following function in Matlab:
function [RawDataKK]=DataCompressKKTest(Data,RXangle,s)
tSize=size(Data,1);
xSize=size(Data,2);
TXSize=size(Data,3);
RXSize=numel(RXangle);
RawDataKK=zeros(tSize,TXSize,RXSize);
DataTemp=zeros(tSize,xSize);
slope = s*sin(RXangle(:))/2;
nShift = round(slope.*((0:xSize-1) – (xSize-1)*(1-sign(RXangle(:)))/2));
for nR=1:RXSize
for nT=1:TXSize
for nx=1:xSize
DataTemp(:,nx)=circshift(Data(:,nx,nT),nShift(nR,nx));
end
RawDataKK(:,nT,nR)=sum(DataTemp,2);
end
end
end
I tried implementing it as a C++ function using the Eigen toolbox and the Matlab Data API for C++. The basic logic of the C++ implementation uses a reindexing approach to implement circshift.
“` lang-cpp
#include <iostream>
#include "mex.hpp"
#include "mexAdapter.hpp"
#include <Eigen/Dense>
#include <MatlabDataArray.hpp>
#include <cmath>
#include <math.h>
#include <omp.h>
class MexFunction : public matlab::mex::Function {
public:
// Factory to create MATLAB data arrays
matlab::data::ArrayFactory factory;
void operator()(matlab::mex::ArgumentList outputs, matlab::mex::ArgumentList inputs) {
checkArguments(outputs, inputs);
// Initialize input parameters
int tSize = inputs[0][0];
int xSize = inputs[0][1];
int TXSize = inputs[0][2];
int RXSize = inputs[0][3];
int RFlen = inputs[0][4];
auto ptr = getDataPtr<std::complex<double>>(inputs[1]);
Eigen::Map< const Eigen::MatrixXcd > Data( ptr, RFlen, xSize );
double s = inputs[2][0];
auto ptr2 = getDataPtr<double>(inputs[3]);
Eigen::Map< const Eigen::VectorXd > RXangle( ptr2, RXSize );
auto ptr3 = getDataPtr<int32_t>(inputs[4]);
Eigen::Map< const Eigen::MatrixXi > indices( ptr3, tSize, xSize*RXSize );
outputs[0] = factory.createArray<std::complex<double>>({static_cast<size_t>(tSize),static_cast<size_t>(TXSize*RXSize)});
auto ptrRecon = getOutDataPtr<std::complex<double>>(outputs[0]);
Eigen::Map<Eigen::MatrixXcd> RFDataKK(ptrRecon,tSize,TXSize*RXSize);
// Get num threads
int numThreads = omp_get_max_threads();
int nProc = omp_get_num_procs();
omp_set_num_threads(nProc*2);
#pragma omp parallel for
for (int nR = 0; nR < RXSize; nR++) {
Eigen::MatrixXcd shiftedData = Eigen::MatrixXcd::Zero(tSize*TXSize,xSize);
for (int nT = 0; nT < TXSize; nT++){
extractData(shiftedData(Eigen::seq(nT*tSize,(nT+1)*tSize-1),Eigen::all),
Data(Eigen::seq(nT*tSize,(nT+1)*tSize-1),Eigen::all),
indices(Eigen::all,Eigen::seq(nR*xSize, (nR+1)*xSize-1)), xSize, tSize);
}
RFDataKK(Eigen::all,Eigen::seq(nR*TXSize,(nR+1)*TXSize-1) ) = shiftedData.rowwise().sum().reshaped(tSize,TXSize);
}
}
void extractData(Eigen::Ref<Eigen::MatrixXcd> shiftedData, const Eigen::Ref<const Eigen::MatrixXcd>& Data,
const Eigen::Ref<const Eigen::MatrixXi>& indices, const long int& xSize, const long int& tSize) {
for (int i = 0; i < tSize*xSize; i++) {
int nt = i % tSize;
int nx = i / tSize;
int row = indices(nt,nx) % tSize;
int col = indices(nt,nx) / tSize;
shiftedData(row,col) = Data(nt,nx);
}
}
void checkArguments(matlab::mex::ArgumentList outputs, matlab::mex::ArgumentList inputs) {
std::shared_ptr<matlab::engine::MATLABEngine> matlabPtr = getEngine();
matlab::data::ArrayFactory factory;
// TODO: Implement remaining checks
}
template <typename T>
const T* getDataPtr(matlab::data::Array arr) {
const matlab::data::TypedArray<T> arr_t = arr;
matlab::data::TypedIterator<const T> it(arr_t.begin());
return it.operator->();
}
template <typename T>
T* getOutDataPtr(matlab::data::Array& arr) {
auto range = matlab::data::getWritableElements<T>(arr);
return range.begin().operator->();
}
};
“`
Where I precompute the values of indices using the following Matlab function:
function linIndices=DataCompressKKIndices(RXangle,s,tSize,xSize,TXSize,RXSize)
shiftedData = zeros(tSize, xSize, TXSize);
RFDatKK = zeros(tSize,TXSize,RXSize);
RFDataKK = zeros(tSize,xSize*RXSize);
slope=s*sin(RXangle(:))/2;
nShift = round(slope.*((0:xSize-1) – (xSize-1)*(1-sign(RXangle(:)))/2));
indices = mod((0:tSize-1).’ + reshape(nShift.’,[],1).’,tSize);
linIndices = indices + repmat((0:xSize-1)*tSize,1,RXSize);
end
When I perform a speed test in Matlab after compiling with the following parameters (with mingw GCC version 8.3), I find that I have not gained a meaningful speedup for the array sizes I am working with. OpenMP parallelization should at least give me an order of magnitude speed up (I have 24 threads on my machine). There are two questions that yields:
1. Why is a reindexing approach slower than doing circshift? A reindexing approach in Matlab (not shown here) is almost 2x slower than using nested for loops and circshift.
2. What exactly could circshift be doing under the hood that is so efficient? Is there some funky pointer arithmetic that could accomplish the functionality of circshift?
Compilation and testing code:
%% Compilation
mingwFlags = {‘CXXFLAGS="$CXXFLAGS -march=native -std=c++14 -fno-math-errno -ffast-math -fopenmp -DNDEBUG -w -Wno-error"’,…
‘LDFLAGS="$LDFLAGS -fopenmp"’,’CXXOPTIMFLAGS="-O3"’};
% ipath is the path to the eigen library.
tic; mex(ipath,mingwFlags{1},mingwFlags{2},mingwFlags{3},’CompressKK.cpp’); toc
tic; mex(ipath,mingwFlags{1},mingwFlags{2},mingwFlags{3},’CompressKKIndices.cpp’); toc
%% Initialize some random data
…
% tSize = 2688, xSize = 192, TXSize = 15, RXSize = 16 for trial cases
%% Timing Test
nTrials = 100;
T = zeros(nTrials,4);
for i = 1:nTrials
tic; indices = DataCompressKKIndices(p.RXangle,s,double(p.szRFframe+1),double(p.numEl),p.na,p.nRX);
RawDataKK3 = CompressKKIndices(param,cRF(1:param(5),p.ConnMap),s,p.RXangle,int32(indices));
RawDataKK3 = reshape(RawDataKK3,[p.szRFframe+1,p.na,p.nRX]); T(i,1) = toc;
tic; RawDataKK=DataCompressKKTest(Data,p.RXangle,s); T(i,2) = toc;
end
chkT = mean(T,1)
Timing Results:
chkT =
C++ version: 0.4867 0.8299 I have the following function in Matlab:
function [RawDataKK]=DataCompressKKTest(Data,RXangle,s)
tSize=size(Data,1);
xSize=size(Data,2);
TXSize=size(Data,3);
RXSize=numel(RXangle);
RawDataKK=zeros(tSize,TXSize,RXSize);
DataTemp=zeros(tSize,xSize);
slope = s*sin(RXangle(:))/2;
nShift = round(slope.*((0:xSize-1) – (xSize-1)*(1-sign(RXangle(:)))/2));
for nR=1:RXSize
for nT=1:TXSize
for nx=1:xSize
DataTemp(:,nx)=circshift(Data(:,nx,nT),nShift(nR,nx));
end
RawDataKK(:,nT,nR)=sum(DataTemp,2);
end
end
end
I tried implementing it as a C++ function using the Eigen toolbox and the Matlab Data API for C++. The basic logic of the C++ implementation uses a reindexing approach to implement circshift.
“` lang-cpp
#include <iostream>
#include "mex.hpp"
#include "mexAdapter.hpp"
#include <Eigen/Dense>
#include <MatlabDataArray.hpp>
#include <cmath>
#include <math.h>
#include <omp.h>
class MexFunction : public matlab::mex::Function {
public:
// Factory to create MATLAB data arrays
matlab::data::ArrayFactory factory;
void operator()(matlab::mex::ArgumentList outputs, matlab::mex::ArgumentList inputs) {
checkArguments(outputs, inputs);
// Initialize input parameters
int tSize = inputs[0][0];
int xSize = inputs[0][1];
int TXSize = inputs[0][2];
int RXSize = inputs[0][3];
int RFlen = inputs[0][4];
auto ptr = getDataPtr<std::complex<double>>(inputs[1]);
Eigen::Map< const Eigen::MatrixXcd > Data( ptr, RFlen, xSize );
double s = inputs[2][0];
auto ptr2 = getDataPtr<double>(inputs[3]);
Eigen::Map< const Eigen::VectorXd > RXangle( ptr2, RXSize );
auto ptr3 = getDataPtr<int32_t>(inputs[4]);
Eigen::Map< const Eigen::MatrixXi > indices( ptr3, tSize, xSize*RXSize );
outputs[0] = factory.createArray<std::complex<double>>({static_cast<size_t>(tSize),static_cast<size_t>(TXSize*RXSize)});
auto ptrRecon = getOutDataPtr<std::complex<double>>(outputs[0]);
Eigen::Map<Eigen::MatrixXcd> RFDataKK(ptrRecon,tSize,TXSize*RXSize);
// Get num threads
int numThreads = omp_get_max_threads();
int nProc = omp_get_num_procs();
omp_set_num_threads(nProc*2);
#pragma omp parallel for
for (int nR = 0; nR < RXSize; nR++) {
Eigen::MatrixXcd shiftedData = Eigen::MatrixXcd::Zero(tSize*TXSize,xSize);
for (int nT = 0; nT < TXSize; nT++){
extractData(shiftedData(Eigen::seq(nT*tSize,(nT+1)*tSize-1),Eigen::all),
Data(Eigen::seq(nT*tSize,(nT+1)*tSize-1),Eigen::all),
indices(Eigen::all,Eigen::seq(nR*xSize, (nR+1)*xSize-1)), xSize, tSize);
}
RFDataKK(Eigen::all,Eigen::seq(nR*TXSize,(nR+1)*TXSize-1) ) = shiftedData.rowwise().sum().reshaped(tSize,TXSize);
}
}
void extractData(Eigen::Ref<Eigen::MatrixXcd> shiftedData, const Eigen::Ref<const Eigen::MatrixXcd>& Data,
const Eigen::Ref<const Eigen::MatrixXi>& indices, const long int& xSize, const long int& tSize) {
for (int i = 0; i < tSize*xSize; i++) {
int nt = i % tSize;
int nx = i / tSize;
int row = indices(nt,nx) % tSize;
int col = indices(nt,nx) / tSize;
shiftedData(row,col) = Data(nt,nx);
}
}
void checkArguments(matlab::mex::ArgumentList outputs, matlab::mex::ArgumentList inputs) {
std::shared_ptr<matlab::engine::MATLABEngine> matlabPtr = getEngine();
matlab::data::ArrayFactory factory;
// TODO: Implement remaining checks
}
template <typename T>
const T* getDataPtr(matlab::data::Array arr) {
const matlab::data::TypedArray<T> arr_t = arr;
matlab::data::TypedIterator<const T> it(arr_t.begin());
return it.operator->();
}
template <typename T>
T* getOutDataPtr(matlab::data::Array& arr) {
auto range = matlab::data::getWritableElements<T>(arr);
return range.begin().operator->();
}
};
“`
Where I precompute the values of indices using the following Matlab function:
function linIndices=DataCompressKKIndices(RXangle,s,tSize,xSize,TXSize,RXSize)
shiftedData = zeros(tSize, xSize, TXSize);
RFDatKK = zeros(tSize,TXSize,RXSize);
RFDataKK = zeros(tSize,xSize*RXSize);
slope=s*sin(RXangle(:))/2;
nShift = round(slope.*((0:xSize-1) – (xSize-1)*(1-sign(RXangle(:)))/2));
indices = mod((0:tSize-1).’ + reshape(nShift.’,[],1).’,tSize);
linIndices = indices + repmat((0:xSize-1)*tSize,1,RXSize);
end
When I perform a speed test in Matlab after compiling with the following parameters (with mingw GCC version 8.3), I find that I have not gained a meaningful speedup for the array sizes I am working with. OpenMP parallelization should at least give me an order of magnitude speed up (I have 24 threads on my machine). There are two questions that yields:
1. Why is a reindexing approach slower than doing circshift? A reindexing approach in Matlab (not shown here) is almost 2x slower than using nested for loops and circshift.
2. What exactly could circshift be doing under the hood that is so efficient? Is there some funky pointer arithmetic that could accomplish the functionality of circshift?
Compilation and testing code:
%% Compilation
mingwFlags = {‘CXXFLAGS="$CXXFLAGS -march=native -std=c++14 -fno-math-errno -ffast-math -fopenmp -DNDEBUG -w -Wno-error"’,…
‘LDFLAGS="$LDFLAGS -fopenmp"’,’CXXOPTIMFLAGS="-O3"’};
% ipath is the path to the eigen library.
tic; mex(ipath,mingwFlags{1},mingwFlags{2},mingwFlags{3},’CompressKK.cpp’); toc
tic; mex(ipath,mingwFlags{1},mingwFlags{2},mingwFlags{3},’CompressKKIndices.cpp’); toc
%% Initialize some random data
…
% tSize = 2688, xSize = 192, TXSize = 15, RXSize = 16 for trial cases
%% Timing Test
nTrials = 100;
T = zeros(nTrials,4);
for i = 1:nTrials
tic; indices = DataCompressKKIndices(p.RXangle,s,double(p.szRFframe+1),double(p.numEl),p.na,p.nRX);
RawDataKK3 = CompressKKIndices(param,cRF(1:param(5),p.ConnMap),s,p.RXangle,int32(indices));
RawDataKK3 = reshape(RawDataKK3,[p.szRFframe+1,p.na,p.nRX]); T(i,1) = toc;
tic; RawDataKK=DataCompressKKTest(Data,p.RXangle,s); T(i,2) = toc;
end
chkT = mean(T,1)
Timing Results:
chkT =
C++ version: 0.4867 0.8299 performance, mex, c++, optimization MATLAB Answers — New Questions
Why do I receive an ‘Invalid input argument of type ‘double’. Input must be a structure or a Java or COM object’ error while loading data in a simbiology fit program?
I deviced a kinetic model using simbiology, simulated it and everything worked fine. Then I loaded a data set from excel containing three columns: ID, Time and concentration. I set ID as group, Time as independent and concentration as depended variables. But when I run the program it says
Invalid input argument of type ‘double’. Input must be a structure or a Java or COM object.
I’ve also tried loading the data directly from the workspace and it gave the same error.
I converted the data to a structure and that is not listed as a valid input type while importing a dataset. I checked online tutorials and everyone seems to be able to load ‘double’ types.
The reaction is just A+B–>null
And dB/dt = -k*[B] and A is constantI deviced a kinetic model using simbiology, simulated it and everything worked fine. Then I loaded a data set from excel containing three columns: ID, Time and concentration. I set ID as group, Time as independent and concentration as depended variables. But when I run the program it says
Invalid input argument of type ‘double’. Input must be a structure or a Java or COM object.
I’ve also tried loading the data directly from the workspace and it gave the same error.
I converted the data to a structure and that is not listed as a valid input type while importing a dataset. I checked online tutorials and everyone seems to be able to load ‘double’ types.
The reaction is just A+B–>null
And dB/dt = -k*[B] and A is constant I deviced a kinetic model using simbiology, simulated it and everything worked fine. Then I loaded a data set from excel containing three columns: ID, Time and concentration. I set ID as group, Time as independent and concentration as depended variables. But when I run the program it says
Invalid input argument of type ‘double’. Input must be a structure or a Java or COM object.
I’ve also tried loading the data directly from the workspace and it gave the same error.
I converted the data to a structure and that is not listed as a valid input type while importing a dataset. I checked online tutorials and everyone seems to be able to load ‘double’ types.
The reaction is just A+B–>null
And dB/dt = -k*[B] and A is constant simbiology, double, structures, data import MATLAB Answers — New Questions
3d arrays Matrix multiplication with a vector
i have 3 D matrix <64x64x64 double> i want to mutiply it with a vector <64×1 double>.i have 3 D matrix <64x64x64 double> i want to mutiply it with a vector <64×1 double>. i have 3 D matrix <64x64x64 double> i want to mutiply it with a vector <64×1 double>. multiplication MATLAB Answers — New Questions
Readtable Delimiters on two similar files gives differing result
Is there any reason why using Readtable to open the following 2 csv files produces different results
Im using readtable as it has the ability to auto detect how many lines to skip, and generally works well – except for the case above and I can’t see why. My aim is to get the real data into a uitable
try
[file,folder]=uigetfile({‘*.csv’;’*.xls’},’Open Image’,app.startfolder);
catch
[file,folder]=uigetfile({‘*.csv’;’*.xls’},’Open Image’,’C:’);
end
fullpath=fullfile(folder,file);
app.startfolder=folder;
T = readtable(fullpath,MissingRule="omitrow",Delimiter=","); %Delimiter="tab"
app.UITable.Data=table2array(T);
This is what I am seeing:
I have tried omitting the Delimiter option in readtable, but with no luck
(Note my header files can be different which is why I want to try and avoid skipping " a known number of " rows.)Is there any reason why using Readtable to open the following 2 csv files produces different results
Im using readtable as it has the ability to auto detect how many lines to skip, and generally works well – except for the case above and I can’t see why. My aim is to get the real data into a uitable
try
[file,folder]=uigetfile({‘*.csv’;’*.xls’},’Open Image’,app.startfolder);
catch
[file,folder]=uigetfile({‘*.csv’;’*.xls’},’Open Image’,’C:’);
end
fullpath=fullfile(folder,file);
app.startfolder=folder;
T = readtable(fullpath,MissingRule="omitrow",Delimiter=","); %Delimiter="tab"
app.UITable.Data=table2array(T);
This is what I am seeing:
I have tried omitting the Delimiter option in readtable, but with no luck
(Note my header files can be different which is why I want to try and avoid skipping " a known number of " rows.) Is there any reason why using Readtable to open the following 2 csv files produces different results
Im using readtable as it has the ability to auto detect how many lines to skip, and generally works well – except for the case above and I can’t see why. My aim is to get the real data into a uitable
try
[file,folder]=uigetfile({‘*.csv’;’*.xls’},’Open Image’,app.startfolder);
catch
[file,folder]=uigetfile({‘*.csv’;’*.xls’},’Open Image’,’C:’);
end
fullpath=fullfile(folder,file);
app.startfolder=folder;
T = readtable(fullpath,MissingRule="omitrow",Delimiter=","); %Delimiter="tab"
app.UITable.Data=table2array(T);
This is what I am seeing:
I have tried omitting the Delimiter option in readtable, but with no luck
(Note my header files can be different which is why I want to try and avoid skipping " a known number of " rows.) readtable, uitable MATLAB Answers — New Questions
I’m trying to connect MATLAB 2023b to a Raspberry Pi 4B. I’ve created the object raspi(“192.168.137.128″,”jiang”,”raspberry”), but I keep encountering this issue.
>> r=raspi("192.168.137.128","jiang","raspberry")
### Updating Raspberry Pi I/O server…
### Connecting to board…
### Connected to 192.168.137.128…
### Creating server folder…
### Transferring source files…
### Building MATLAB I/O server…
Error executing command "make ONLY_MATLAB_IO=1 -C /opt/MATLAB/mw_server_v23.2.0 -f Makefile". Details:
STDERR: ‘writeReadSPI’:
IO_wrapperSPI.c:210:12: warning: passing argument 1 of ‘memcpy’ discards ‘const’ qualifier from pointer target type
[-Wdiscarded-qualifiers]
210 | memcpy(wrData, &payloadBufferRx[index], dataLength); // Copy data to be written to local buffer
| ^~~~~~
In file included from IO_include.h:18,
from PeripheralToHandle.h:13,
from IO_peripheralInclude.h:16,
from IO_wrapperSPI.h:15,
from IO_wrapperSPI.c:10:
/usr/include/string.h:43:39: note: expected ‘void * restrict’ but argument is of type ‘const uint8_T *’ {aka ‘const unsigned char
*’}
43 | extern void *memcpy (void *__restrict __dest, const void *__restrict __src,
| ~~~~~~~~~~~~~~~~~^~~~~~
IO_wrapperSPI.c:189:32: warning: unused variable ‘ctr’ [-Wunused-variable]
189 | uint32_T SPIBus,dataLength,ctr;
| ^~~
/opt/userland/host_applications/linux/apps/raspicam/RaspiHelpers.c: In function ‘print_app_details’:
/opt/userland/host_applications/linux/apps/raspicam/RaspiHelpers.c:69:57: warning: implicit declaration of function ‘basename’;
did you mean ‘rename’? [-Wimplicit-function-declaration]
69 | fprintf(fd, "n"%s" Camera App (commit %s%s)nn", basename(app_name), GIT_COMMIT_ID, TAINTED);
| ^~~~~~~~
| rename
/opt/userland/host_applications/linux/apps/raspicam/RaspiHelpers.c:69:22: warning: format ‘%s’ expects argument of type ‘char *’,
but argument 3 has type ‘int’ [-Wformat=]
69 | fprintf(fd, "n"%s" Camera App (commit %s%s)nn", basename(app_name), GIT_COMMIT_ID, TAINTED);
| ~^ ~~~~~~~~~~~~~~~~~~
| | |
| char * int
| %d
/opt/userland/host_applications/linux/apps/raspicam/RaspiCommonSettings.c: In function ‘raspicommonsettings_parse_cmdline’:
/opt/userland/host_applications/linux/apps/raspicam/RaspiCommonSettings.c:149:32: warning: implicit declaration of function
‘basename’; did you mean ‘rename’? [-Wimplicit-function-declaration]
149 | display_valid_parameters(basename(get_app_name()), app_help);
| ^~~~~~~~
| rename
/opt/userland/host_applications/linux/apps/raspicam/RaspiCommonSettings.c:149:32: warning: passing argument 1 of
‘display_valid_parameters’ makes pointer from integer without a cast [-Wint-conversion]
149 | display_valid_parameters(basename(get_app_name()), app_help);
| ^~~~~~~~~~~~~~~~~~~~~~~~
| |
| int
In file included from /opt/userland/host_applications/linux/apps/raspicam/RaspiCommonSettings.c:57:
/opt/userland/host_applications/linux/apps/raspicam/RaspiHelpers.h:32:37: note: expected ‘char *’ but argument is of type ‘int’
32 | void display_valid_parameters(char *name, void (*app_help)(char*));
| ~~~~~~^~~~
frameBuffer.c: In function ‘EXT_FRAMEBUFFER_INIT’:
frameBuffer.c:54:55: warning: comparison between pointer and zero character constant [-Wpointer-compare]
54 | for(ii=0;ii<100 & glob_buffer.gl_pathv[i] != ”;ii++)
| ^~
frameBuffer.c:54:31: note: did you mean to dereference the pointer?
54 | for(ii=0;ii<100 & glob_buffer.gl_pathv[i] != ”;ii++)
| ^
frameBuffer.c:54:24: warning: suggest parentheses around comparison in operand of ‘&’ [-Wparentheses]
54 | for(ii=0;ii<100 & glob_buffer.gl_pathv[i] != ”;ii++)
| ~~^~~~
frameBuffer.c: In function ‘EXT_FRAMEBUFFER_WRITEPIXEL’:
frameBuffer.c:80:9: warning: unused variable ‘ii’ [-Wunused-variable]
80 | int ii ;
| ^~
frameBuffer.c: In function ‘EXT_FRAMEBUFFER_DISPLAYIMAGE’:
frameBuffer.c:107:17: warning: suggest parentheses around comparison in operand of ‘&’ [-Wparentheses]
107 | for(ii=0; ii<100 & sh_fbname[ii] != ”; ii++)
| ~~^~~~
frameBuffer.c:105:10: warning: variable ‘fileName’ set but not used [-Wunused-but-set-variable]
105 | char fileName[100];
| ^~~~~~~~
frameBuffer.c:104:9: warning: unused variable ‘pxllocation’ [-Wunused-variable]
104 | int pxllocation=0;
| ^~~~~~~~~~~
joystick.c: In function ‘EXT_JOYSTICK_INIT’:
joystick.c:45:56: warning: comparison between pointer and zero character constant [-Wpointer-compare]
45 | for(ii=0; ii<100 & glob_buffer.gl_pathv[i] != ”; ii++)
| ^~
joystick.c:45:32: note: did you mean to dereference the pointer?
45 | for(ii=0; ii<100 & glob_buffer.gl_pathv[i] != ”; ii++)
| ^
joystick.c:45:25: warning: suggest parentheses around comparison in operand of ‘&’ [-Wparentheses]
45 | for(ii=0; ii<100 & glob_buffer.gl_pathv[i] != ”; ii++)
| ~~^~~~
joystick.c: In function ‘EXT_JOYSTICK_READ’:
joystick.c:82:17: warning: suggest parentheses around comparison in operand of ‘&’ [-Wparentheses]
82 | for(ii=0;(ii<100 & sh_evdevName[ii] != ”);ii++)
| ~~^~~~
/usr/bin/ld: cannot find -lmmal: No such file or directory
/usr/bin/ld: cannot find -lmmal_core: No such file or directory
/usr/bin/ld: cannot find -lmmal_util: No such file or directory
/usr/bin/ld: cannot find -lmmal_vc_client: No such file or directory
collect2: error: ld returned 1 exit status
make: *** [Makefile:95: build] Error 1
STDOUT: make: Entering directory ‘/opt/MATLAB/mw_server_v23.2.0’
[Compiling] IO_wrapperv4l2.c
gcc -c -g -O0 -D_DEBUG -Wall -I/opt/userland -I/opt/userland/host_applications/linux/libs/bcm_host/include
-I/opt/userland/interface/vcos -I/opt/userland/interface/vcos/pthreads -I/opt/userland/interface/vmcs_host/linux
-I/opt/userland/host_applications/linux/apps/raspicam -I/opt/nanomsg/include -Winline -pipe -D_DEBUG -D_MATLABIO_
IO_wrapperv4l2.c -o obj/IO_wrapperv4l2.o
[Compiling] MW_PWM.c
gcc -c -g -O0 -D_DEBUG -Wall -I/opt/userland -I/opt/userland/host_applications/linux/libs/bcm_host/include
-I/opt/userland/interface/vcos -I/opt/userland/interface/vcos/pthreads -I/opt/userland/interface/vmcs_host/linux
-I/opt/userland/host_applications/linux/apps/raspicam -I/opt/nanomsg/include -Winline -pipe -D_DEBUG -D_MATLABIO_ MW_PWM.c -o
obj/MW_PWM.o
[Compiling] MW_pigs.c
gcc -c -g -O0 -D_DEBUG -Wall -I/opt/userland -I/opt/userland/host_applications/linux/libs/bcm_host/include
-I/opt/userland/interface/vcos -I/opt/userland/interface/vcos/pthreads -I/opt/userland/interface/vmcs_host/linux
-I/opt/userland/host_applications/linux/apps/raspicam -I/opt/nanomsg/include -Winline -pipe -D_DEBUG -D_MATLABIO_ MW_pigs.c -o
obj/MW_pigs.o
[Compiling] sharedServer.c
gcc -c -g -O0 -D_DEBUG -Wall -I/opt/userland -I/opt/userland/host_applications/linux/libs/bcm_host/include
-I/opt/userland/interface/vcos -I/opt/userland/interface/vcos/pthreads -I/opt/userland/interface/vmcs_host/linux
-I/opt/userland/host_applications/linux/apps/raspicam -I/opt/nanomsg/include -Winline -pipe -D_DEBUG -D_MATLABIO_ sharedServer.c
-o obj/sharedServer.o
[Compiling] IO_wrapperCameraboard.c
gcc -c -g -O0 -D_DEBUG -Wall -I/opt/userland -I/opt/userland/host_applications/linux/libs/bcm_host/include
-I/opt/userland/interface/vcos -I/opt/userland/interface/vcos/pthreads -I/opt/userland/interface/vmcs_host/linux
-I/opt/userland/host_applications/linux/apps/raspicam -I/opt/nanomsg/include -Winline -pipe -D_DEBUG -D_MATLABIO_
IO_wrapperCameraboard.c -o obj/IO_wrapperCameraboard.o
[Compiling] IO_wrapperArducamMultiAdapter.c
gcc -c -g -O0 -D_DEBUG -Wall -I/opt/userland -I/opt/userland/host_applications/linux/libs/bcm_host/include
-I/opt/userland/interface/vcos -I/opt/userland/interface/vcos/pthreads -I/opt/userland/interface/vmcs_host/linux
-I/opt/userland/host_applications/linux/apps/raspicam -I/opt/nanomsg/include -Winline -pipe -D_DEBUG -D_MATLABIO_
IO_wrapperArducamMultiAdapter.c -o obj/IO_wrapperArducamMultiAdapter.o
[Compiling] mw_wrapperCANChannel.c
gcc -c -g -O0 -D_DEBUG -Wall -I/opt/userland -I/opt/userland/host_applications/linux/libs/bcm_host/include
-I/opt/userland/interface/vcos -I/opt/userland/interface/vcos/pthreads -I/opt/userland/interface/vmcs_host/linux
-I/opt/userland/host_applications/linux/apps/raspicam -I/opt/nanomsg/include -Winline -pipe -D_DEBUG -D_MATLABIO_
mw_wrapperCANChannel.c -o obj/mw_wrapperCANChannel.o
[Compiling] LED.c
gcc -c -g -O0 -D_DEBUG -Wall -I/opt/userland -I/opt/userland/host_applications/linux/libs/bcm_host/include
-I/opt/userland/interface/vcos -I/opt/userland/interface/vcos/pthreads -I/opt/userland/interface/vmcs_host/linux
-I/opt/userland/host_applications/linux/apps/raspicam -I/opt/nanomsg/include -Winline -pipe -D_DEBUG -D_MATLABIO_ LED.c -o
obj/LED.o
[Compiling] picam.c
gcc -c -g -O0 -D_DEBUG -Wall -I/opt/userland -I/opt/userland/host_applications/linux/libs/bcm_host/include
-I/opt/userland/interface/vcos -I/opt/userland/interface/vcos/pthreads -I/opt/userland/interface/vmcs_host/linux
-I/opt/userland/host_applications/linux/apps/raspicam -I/opt/nanomsg/include -Winline -pipe -D_DEBUG -D_MATLABIO_ picam.c -o
obj/picam.o
[Compiling] arducamMultiAdapter.c
gcc -c -g -O0 -D_DEBUG -Wall -I/opt/userland -I/opt/userland/host_applications/linux/libs/bcm_host/include
-I/opt/userland/interface/vcos -I/opt/userland/interface/vcos/pthreads -I/opt/userland/interface/vmcs_host/linux
-I/opt/userland/host_applications/linux/apps/raspicam -I/opt/nanomsg/include -Winline -pipe -D_DEBUG -D_MATLABIO_
arducamMultiAdapter.c -o obj/arducamMultiAdapter.o
[Compiling] system.c
gcc -c -g -O0 -D_DEBUG -Wall -I/opt/userland -I/opt/userland/host_applications/linux/libs/bcm_host/include
-I/opt/userland/interface/vcos -I/opt/userland/interface/vcos/pthreads -I/opt/userland/interface/vmcs_host/linux
-I/opt/userland/host_applications/linux/apps/raspicam -I/opt/nanomsg/include -Winline -pipe -D_DEBUG -D_MATLABIO_ system.c -o
obj/system.o
[Compiling] IO_wrapperLED.c
gcc -c -g -O0 -D_DEBUG -Wall -I/opt/userland -I/opt/userland/host_applications/linux/libs/bcm_host/include
-I/opt/userland/interface/vcos -I/opt/userland/interface/vcos/pthreads -I/opt/userland/interface/vmcs_host/linux
-I/opt/userland/host_applications/linux/apps/raspicam -I/opt/nanomsg/include -Winline -pipe -D_DEBUG -D_MATLABIO_ IO_wrapperLED.c
-o obj/IO_wrapperLED.o
[Compiling] MW_digitalIO.c
gcc -c -g -O0 -D_DEBUG -Wall -I/opt/userland -I/opt/userland/host_applications/linux/libs/bcm_host/include
-I/opt/userland/interface/vcos -I/opt/userland/interface/vcos/pthreads -I/opt/userland/interface/vmcs_host/linux
-I/opt/userland/host_applications/linux/apps/raspicam -I/opt/nanomsg/include -Winline -pipe -D_DEBUG -D_MATLABIO_ MW_digitalIO.c
-o obj/MW_digitalIO.o
[Compiling] customFunction.c
gcc -c -g -O0 -D_DEBUG -Wall -I/opt/userland -I/opt/userland/host_applications/linux/libs/bcm_host/include
-I/opt/userland/interface/vcos -I/opt/userland/interface/vcos/pthreads -I/opt/userland/interface/vmcs_host/linux
-I/opt/userland/host_applications/linux/apps/raspicam -I/opt/nanomsg/include -Winline -pipe -D_DEBUG -D_MATLABIO_
customFunction.c -o obj/customFunction.o
[Compiling] servoRaspi.c
gcc -c -g -O0 -D_DEBUG -Wall -I/opt/userland -I/opt/userland/host_applications/linux/libs/bcm_host/include
-I/opt/userland/interface/vcos -I/opt/userland/interface/vcos/pthreads -I/opt/userland/interface/vmcs_host/linux
-I/opt/userland/host_applications/linux/apps/raspicam -I/opt/nanomsg/include -Winline -pipe -D_DEBUG -D_MATLABIO_ servoRaspi.c -o
obj/servoRaspi.o
[Compiling] IO_checksum.c
gcc -c -g -O0 -D_DEBUG -Wall -I/opt/userland -I/opt/userland/host_applications/linux/libs/bcm_host/include
-I/opt/userland/interface/vcos -I/opt/userland/interface/vcos/pthreads -I/opt/userland/interface/vmcs_host/linux
-I/opt/userland/host_applications/linux/apps/raspicam -I/opt/nanomsg/include -Winline -pipe -D_DEBUG -D_MATLABIO_ IO_checksum.c
-o obj/IO_checksum.o
[Compiling] IO_packet.c
gcc -c -g -O0 -D_DEBUG -Wall -I/opt/userland -I/opt/userland/host_applications/linux/libs/bcm_host/include
-I/opt/userland/interface/vcos -I/opt/userland/interface/vcos/pthreads -I/opt/userland/interface/vmcs_host/linux
-I/opt/userland/host_applications/linux/apps/raspicam -I/opt/nanomsg/include -Winline -pipe -D_DEBUG -D_MATLABIO_ IO_packet.c -o
obj/IO_packet.o
[Compiling] IO_standardperipherals.c
gcc -c -g -O0 -D_DEBUG -Wall -I/opt/userland -I/opt/userland/host_applications/linux/libs/bcm_host/include
-I/opt/userland/interface/vcos -I/opt/userland/interface/vcos/pthreads -I/opt/userland/interface/vmcs_host/linux
-I/opt/userland/host_applications/linux/apps/raspicam -I/opt/nanomsg/include -Winline -pipe -D_DEBUG -D_MATLABIO_
IO_standardperipherals.c -o obj/IO_standardperipherals.o
[Compiling] IO_wrapperI2C.c
gcc -c -g -O0 -D_DEBUG -Wall -I/opt/userland -I/opt/userland/host_applications/linux/libs/bcm_host/include
-I/opt/userland/interface/vcos -I/opt/userland/interface/vcos/pthreads -I/opt/userland/interface/vmcs_host/linux
-I/opt/userland/host_applications/linux/apps/raspicam -I/opt/nanomsg/include -Winline -pipe -D_DEBUG -D_MATLABIO_ IO_wrapperI2C.c
-o obj/IO_wrapperI2C.o
[Compiling] IO_wrapperPulseIn.c
gcc -c -g -O0 -D_DEBUG -Wall -I/opt/userland -I/opt/userland/host_applications/linux/libs/bcm_host/include
-I/opt/userland/interface/vcos -I/opt/userland/interface/vcos/pthreads -I/opt/userland/interface/vmcs_host/linux
-I/opt/userland/host_applications/linux/apps/raspicam -I/opt/nanomsg/include -Winline -pipe -D_DEBUG -D_MATLABIO_
IO_wrapperPulseIn.c -o obj/IO_wrapperPulseIn.o
[Compiling] IO_wrapperSCI.c
gcc -c -g -O0 -D_DEBUG -Wall -I/opt/userland -I/opt/userland/host_applications/linux/libs/bcm_host/include
-I/opt/userland/interface/vcos -I/opt/userland/interface/vcos/pthreads -I/opt/userland/interface/vmcs_host/linux
-I/opt/userland/host_applications/linux/apps/raspicam -I/opt/nanomsg/include -Winline -pipe -D_DEBUG -D_MATLABIO_ IO_wrapperSCI.c
-o obj/IO_wrapperSCI.o
[Compiling] PeripheralToHandle.c
gcc -c -g -O0 -D_DEBUG -Wall -I/opt/userland -I/opt/userland/host_applications/linux/libs/bcm_host/include
-I/opt/userland/interface/vcos -I/opt/userland/interface/vcos/pthreads -I/opt/userland/interface/vmcs_host/linux
-I/opt/userland/host_applications/linux/apps/raspicam -I/opt/nanomsg/include -Winline -pipe -D_DEBUG -D_MATLABIO_
PeripheralToHandle.c -o obj/PeripheralToHandle.o
[Compiling] IO_debug.c
gcc -c -g -O0 -D_DEBUG -Wall -I/opt/userland -I/opt/userland/host_applications/linux/libs/bcm_host/include
-I/opt/userland/interface/vcos -I/opt/userland/interface/vcos/pthreads -I/opt/userland/interface/vmcs_host/linux
-I/opt/userland/host_applications/linux/apps/raspicam -I/opt/nanomsg/include -Winline -pipe -D_DEBUG -D_MATLABIO_ IO_debug.c -o
obj/IO_debug.o
[Compiling] IO_server.c
gcc -c -g -O0 -D_DEBUG -Wall -I/opt/userland -I/opt/userland/host_applications/linux/libs/bcm_host/include
-I/opt/userland/interface/vcos -I/opt/userland/interface/vcos/pthreads -I/opt/userland/interface/vmcs_host/linux
-I/opt/userland/host_applications/linux/apps/raspicam -I/opt/nanomsg/include -Winline -pipe -D_DEBUG -D_MATLABIO_ IO_server.c -o
obj/IO_server.o
[Compiling] IO_utilities.c
gcc -c -g -O0 -D_DEBUG -Wall -I/opt/userland -I/opt/userland/host_applications/linux/libs/bcm_host/include
-I/opt/userland/interface/vcos -I/opt/userland/interface/vcos/pthreads -I/opt/userland/interface/vmcs_host/linux
-I/opt/userland/host_applications/linux/apps/raspicam -I/opt/nanomsg/include -Winline -pipe -D_DEBUG -D_MATLABIO_ IO_utilities.c
-o obj/IO_utilities.o
[Compiling] IO_wrapperDigitalIO.c
gcc -c -g -O0 -D_DEBUG -Wall -I/opt/userland -I/opt/userland/host_applications/linux/libs/bcm_host/include
-I/opt/userland/interface/vcos -I/opt/userland/interface/vcos/pthreads -I/opt/userland/interface/vmcs_host/linux
-I/opt/userland/host_applications/linux/apps/raspicam -I/opt/nanomsg/include -Winline -pipe -D_DEBUG -D_MATLABIO_
IO_wrapperDigitalIO.c -o obj/IO_wrapperDigitalIO.o
[Compiling] IO_wrapperPWM.c
gcc -c -g -O0 -D_DEBUG -Wall -I/opt/userland -I/opt/userland/host_applications/linux/libs/bcm_host/include
-I/opt/userland/interface/vcos -I/opt/userland/interface/vcos/pthreads -I/opt/userland/interface/vmcs_host/linux
-I/opt/userland/host_applications/linux/apps/raspicam -I/opt/nanomsg/include -Winline -pipe -D_DEBUG -D_MATLABIO_ IO_wrapperPWM.c
-o obj/IO_wrapperPWM.o
[Compiling] IO_wrapperSPI.c
gcc -c -g -O0 -D_DEBUG -Wall -I/opt/userland -I/opt/userland/host_applications/linux/libs/bcm_host/include
-I/opt/userland/interface/vcos -I/opt/userland/interface/vcos/pthreads -I/opt/userland/interface/vmcs_host/linux
-I/opt/userland/host_applications/linux/apps/raspicam -I/opt/nanomsg/include -Winline -pipe -D_DEBUG -D_MATLABIO_ IO_wrapperSPI.c
-o obj/IO_wrapperSPI.o
[Compiling] /opt/userland/host_applications/linux/apps/raspicam/RaspiCamControl.c
gcc -c -g -O0 -D_DEBUG -Wall -I/opt/userland -I/opt/userland/host_applications/linux/libs/bcm_host/include
-I/opt/userland/interface/vcos -I/opt/userland/interface/vcos/pthreads -I/opt/userland/interface/vmcs_host/linux
-I/opt/userland/host_applications/linux/apps/raspicam -I/opt/nanomsg/include -Winline -pipe -D_DEBUG -D_MATLABIO_
/opt/userland/host_applications/linux/apps/raspicam/RaspiCamControl.c -o obj/RaspiCamControl.o
[Compiling] /opt/userland/host_applications/linux/apps/raspicam/RaspiHelpers.c
gcc -c -g -O0 -D_DEBUG -Wall -I/opt/userland -I/opt/userland/host_applications/linux/libs/bcm_host/include
-I/opt/userland/interface/vcos -I/opt/userland/interface/vcos/pthreads -I/opt/userland/interface/vmcs_host/linux
-I/opt/userland/host_applications/linux/apps/raspicam -I/opt/nanomsg/include -Winline -pipe -D_DEBUG -D_MATLABIO_
/opt/userland/host_applications/linux/apps/raspicam/RaspiHelpers.c -o obj/RaspiHelpers.o
[Compiling] /opt/userland/host_applications/linux/apps/raspicam/RaspiPreview.c
gcc -c -g -O0 -D_DEBUG -Wall -I/opt/userland -I/opt/userland/host_applications/linux/libs/bcm_host/include
-I/opt/userland/interface/vcos -I/opt/userland/interface/vcos/pthreads -I/opt/userland/interface/vmcs_host/linux
-I/opt/userland/host_applications/linux/apps/raspicam -I/opt/nanomsg/include -Winline -pipe -D_DEBUG -D_MATLABIO_
/opt/userland/host_applications/linux/apps/raspicam/RaspiPreview.c -o obj/RaspiPreview.o
[Compiling] /opt/userland/host_applications/linux/apps/raspicam/RaspiCLI.c
gcc -c -g -O0 -D_DEBUG -Wall -I/opt/userland -I/opt/userland/host_applications/linux/libs/bcm_host/include
-I/opt/userland/interface/vcos -I/opt/userland/interface/vcos/pthreads -I/opt/userland/interface/vmcs_host/linux
-I/opt/userland/host_applications/linux/apps/raspicam -I/opt/nanomsg/include -Winline -pipe -D_DEBUG -D_MATLABIO_
/opt/userland/host_applications/linux/apps/raspicam/RaspiCLI.c -o obj/RaspiCLI.o
[Compiling] /opt/userland/host_applications/linux/apps/raspicam/RaspiCommonSettings.c
gcc -c -g -O0 -D_DEBUG -Wall -I/opt/userland -I/opt/userland/host_applications/linux/libs/bcm_host/include
-I/opt/userland/interface/vcos -I/opt/userland/interface/vcos/pthreads -I/opt/userland/interface/vmcs_host/linux
-I/opt/userland/host_applications/linux/apps/raspicam -I/opt/nanomsg/include -Winline -pipe -D_DEBUG -D_MATLABIO_
/opt/userland/host_applications/linux/apps/raspicam/RaspiCommonSettings.c -o obj/RaspiCommonSettings.o
[Compiling] frameBuffer.c
gcc -c -g -O0 -D_DEBUG -Wall -I/opt/userland -I/opt/userland/host_applications/linux/libs/bcm_host/include
-I/opt/userland/interface/vcos -I/opt/userland/interface/vcos/pthreads -I/opt/userland/interface/vmcs_host/linux
-I/opt/userland/host_applications/linux/apps/raspicam -I/opt/nanomsg/include -Winline -pipe -D_DEBUG -D_MATLABIO_ frameBuffer.c
-o obj/frameBuffer.o
[Compiling] frameBufferRaspi.c
gcc -c -g -O0 -D_DEBUG -Wall -I/opt/userland -I/opt/userland/host_applications/linux/libs/bcm_host/include
-I/opt/userland/interface/vcos -I/opt/userland/interface/vcos/pthreads -I/opt/userland/interface/vmcs_host/linux
-I/opt/userland/host_applications/linux/apps/raspicam -I/opt/nanomsg/include -Winline -pipe -D_DEBUG -D_MATLABIO_
frameBufferRaspi.c -o obj/frameBufferRaspi.o
[Compiling] joystick.c
gcc -c -g -O0 -D_DEBUG -Wall -I/opt/userland -I/opt/userland/host_applications/linux/libs/bcm_host/include
-I/opt/userland/interface/vcos -I/opt/userland/interface/vcos/pthreads -I/opt/userland/interface/vmcs_host/linux
-I/opt/userland/host_applications/linux/apps/raspicam -I/opt/nanomsg/include -Winline -pipe -D_DEBUG -D_MATLABIO_ joystick.c -o
obj/joystick.o
[Compiling] joystickRaspi.c
gcc -c -g -O0 -D_DEBUG -Wall -I/opt/userland -I/opt/userland/host_applications/linux/libs/bcm_host/include
-I/opt/userland/interface/vcos -I/opt/userland/interface/vcos/pthreads -I/opt/userland/interface/vmcs_host/linux
-I/opt/userland/host_applications/linux/apps/raspicam -I/opt/nanomsg/include -Winline -pipe -D_DEBUG -D_MATLABIO_ joystickRaspi.c
-o obj/joystickRaspi.o
[Compiling] runCommand.c
gcc -c -g -O0 -D_DEBUG -Wall -I/opt/userland -I/opt/userland/host_applications/linux/libs/bcm_host/include
-I/opt/userland/interface/vcos -I/opt/userland/interface/vcos/pthreads -I/opt/userland/interface/vmcs_host/linux
-I/opt/userland/host_applications/linux/apps/raspicam -I/opt/nanomsg/include -Winline -pipe -D_DEBUG -D_MATLABIO_ runCommand.c -o
obj/runCommand.o
echo [Linking]
[Linking]
make: Leaving directory ‘/opt/MATLAB/mw_server_v23.2.0’>> r=raspi("192.168.137.128","jiang","raspberry")
### Updating Raspberry Pi I/O server…
### Connecting to board…
### Connected to 192.168.137.128…
### Creating server folder…
### Transferring source files…
### Building MATLAB I/O server…
Error executing command "make ONLY_MATLAB_IO=1 -C /opt/MATLAB/mw_server_v23.2.0 -f Makefile". Details:
STDERR: ‘writeReadSPI’:
IO_wrapperSPI.c:210:12: warning: passing argument 1 of ‘memcpy’ discards ‘const’ qualifier from pointer target type
[-Wdiscarded-qualifiers]
210 | memcpy(wrData, &payloadBufferRx[index], dataLength); // Copy data to be written to local buffer
| ^~~~~~
In file included from IO_include.h:18,
from PeripheralToHandle.h:13,
from IO_peripheralInclude.h:16,
from IO_wrapperSPI.h:15,
from IO_wrapperSPI.c:10:
/usr/include/string.h:43:39: note: expected ‘void * restrict’ but argument is of type ‘const uint8_T *’ {aka ‘const unsigned char
*’}
43 | extern void *memcpy (void *__restrict __dest, const void *__restrict __src,
| ~~~~~~~~~~~~~~~~~^~~~~~
IO_wrapperSPI.c:189:32: warning: unused variable ‘ctr’ [-Wunused-variable]
189 | uint32_T SPIBus,dataLength,ctr;
| ^~~
/opt/userland/host_applications/linux/apps/raspicam/RaspiHelpers.c: In function ‘print_app_details’:
/opt/userland/host_applications/linux/apps/raspicam/RaspiHelpers.c:69:57: warning: implicit declaration of function ‘basename’;
did you mean ‘rename’? [-Wimplicit-function-declaration]
69 | fprintf(fd, "n"%s" Camera App (commit %s%s)nn", basename(app_name), GIT_COMMIT_ID, TAINTED);
| ^~~~~~~~
| rename
/opt/userland/host_applications/linux/apps/raspicam/RaspiHelpers.c:69:22: warning: format ‘%s’ expects argument of type ‘char *’,
but argument 3 has type ‘int’ [-Wformat=]
69 | fprintf(fd, "n"%s" Camera App (commit %s%s)nn", basename(app_name), GIT_COMMIT_ID, TAINTED);
| ~^ ~~~~~~~~~~~~~~~~~~
| | |
| char * int
| %d
/opt/userland/host_applications/linux/apps/raspicam/RaspiCommonSettings.c: In function ‘raspicommonsettings_parse_cmdline’:
/opt/userland/host_applications/linux/apps/raspicam/RaspiCommonSettings.c:149:32: warning: implicit declaration of function
‘basename’; did you mean ‘rename’? [-Wimplicit-function-declaration]
149 | display_valid_parameters(basename(get_app_name()), app_help);
| ^~~~~~~~
| rename
/opt/userland/host_applications/linux/apps/raspicam/RaspiCommonSettings.c:149:32: warning: passing argument 1 of
‘display_valid_parameters’ makes pointer from integer without a cast [-Wint-conversion]
149 | display_valid_parameters(basename(get_app_name()), app_help);
| ^~~~~~~~~~~~~~~~~~~~~~~~
| |
| int
In file included from /opt/userland/host_applications/linux/apps/raspicam/RaspiCommonSettings.c:57:
/opt/userland/host_applications/linux/apps/raspicam/RaspiHelpers.h:32:37: note: expected ‘char *’ but argument is of type ‘int’
32 | void display_valid_parameters(char *name, void (*app_help)(char*));
| ~~~~~~^~~~
frameBuffer.c: In function ‘EXT_FRAMEBUFFER_INIT’:
frameBuffer.c:54:55: warning: comparison between pointer and zero character constant [-Wpointer-compare]
54 | for(ii=0;ii<100 & glob_buffer.gl_pathv[i] != ”;ii++)
| ^~
frameBuffer.c:54:31: note: did you mean to dereference the pointer?
54 | for(ii=0;ii<100 & glob_buffer.gl_pathv[i] != ”;ii++)
| ^
frameBuffer.c:54:24: warning: suggest parentheses around comparison in operand of ‘&’ [-Wparentheses]
54 | for(ii=0;ii<100 & glob_buffer.gl_pathv[i] != ”;ii++)
| ~~^~~~
frameBuffer.c: In function ‘EXT_FRAMEBUFFER_WRITEPIXEL’:
frameBuffer.c:80:9: warning: unused variable ‘ii’ [-Wunused-variable]
80 | int ii ;
| ^~
frameBuffer.c: In function ‘EXT_FRAMEBUFFER_DISPLAYIMAGE’:
frameBuffer.c:107:17: warning: suggest parentheses around comparison in operand of ‘&’ [-Wparentheses]
107 | for(ii=0; ii<100 & sh_fbname[ii] != ”; ii++)
| ~~^~~~
frameBuffer.c:105:10: warning: variable ‘fileName’ set but not used [-Wunused-but-set-variable]
105 | char fileName[100];
| ^~~~~~~~
frameBuffer.c:104:9: warning: unused variable ‘pxllocation’ [-Wunused-variable]
104 | int pxllocation=0;
| ^~~~~~~~~~~
joystick.c: In function ‘EXT_JOYSTICK_INIT’:
joystick.c:45:56: warning: comparison between pointer and zero character constant [-Wpointer-compare]
45 | for(ii=0; ii<100 & glob_buffer.gl_pathv[i] != ”; ii++)
| ^~
joystick.c:45:32: note: did you mean to dereference the pointer?
45 | for(ii=0; ii<100 & glob_buffer.gl_pathv[i] != ”; ii++)
| ^
joystick.c:45:25: warning: suggest parentheses around comparison in operand of ‘&’ [-Wparentheses]
45 | for(ii=0; ii<100 & glob_buffer.gl_pathv[i] != ”; ii++)
| ~~^~~~
joystick.c: In function ‘EXT_JOYSTICK_READ’:
joystick.c:82:17: warning: suggest parentheses around comparison in operand of ‘&’ [-Wparentheses]
82 | for(ii=0;(ii<100 & sh_evdevName[ii] != ”);ii++)
| ~~^~~~
/usr/bin/ld: cannot find -lmmal: No such file or directory
/usr/bin/ld: cannot find -lmmal_core: No such file or directory
/usr/bin/ld: cannot find -lmmal_util: No such file or directory
/usr/bin/ld: cannot find -lmmal_vc_client: No such file or directory
collect2: error: ld returned 1 exit status
make: *** [Makefile:95: build] Error 1
STDOUT: make: Entering directory ‘/opt/MATLAB/mw_server_v23.2.0’
[Compiling] IO_wrapperv4l2.c
gcc -c -g -O0 -D_DEBUG -Wall -I/opt/userland -I/opt/userland/host_applications/linux/libs/bcm_host/include
-I/opt/userland/interface/vcos -I/opt/userland/interface/vcos/pthreads -I/opt/userland/interface/vmcs_host/linux
-I/opt/userland/host_applications/linux/apps/raspicam -I/opt/nanomsg/include -Winline -pipe -D_DEBUG -D_MATLABIO_
IO_wrapperv4l2.c -o obj/IO_wrapperv4l2.o
[Compiling] MW_PWM.c
gcc -c -g -O0 -D_DEBUG -Wall -I/opt/userland -I/opt/userland/host_applications/linux/libs/bcm_host/include
-I/opt/userland/interface/vcos -I/opt/userland/interface/vcos/pthreads -I/opt/userland/interface/vmcs_host/linux
-I/opt/userland/host_applications/linux/apps/raspicam -I/opt/nanomsg/include -Winline -pipe -D_DEBUG -D_MATLABIO_ MW_PWM.c -o
obj/MW_PWM.o
[Compiling] MW_pigs.c
gcc -c -g -O0 -D_DEBUG -Wall -I/opt/userland -I/opt/userland/host_applications/linux/libs/bcm_host/include
-I/opt/userland/interface/vcos -I/opt/userland/interface/vcos/pthreads -I/opt/userland/interface/vmcs_host/linux
-I/opt/userland/host_applications/linux/apps/raspicam -I/opt/nanomsg/include -Winline -pipe -D_DEBUG -D_MATLABIO_ MW_pigs.c -o
obj/MW_pigs.o
[Compiling] sharedServer.c
gcc -c -g -O0 -D_DEBUG -Wall -I/opt/userland -I/opt/userland/host_applications/linux/libs/bcm_host/include
-I/opt/userland/interface/vcos -I/opt/userland/interface/vcos/pthreads -I/opt/userland/interface/vmcs_host/linux
-I/opt/userland/host_applications/linux/apps/raspicam -I/opt/nanomsg/include -Winline -pipe -D_DEBUG -D_MATLABIO_ sharedServer.c
-o obj/sharedServer.o
[Compiling] IO_wrapperCameraboard.c
gcc -c -g -O0 -D_DEBUG -Wall -I/opt/userland -I/opt/userland/host_applications/linux/libs/bcm_host/include
-I/opt/userland/interface/vcos -I/opt/userland/interface/vcos/pthreads -I/opt/userland/interface/vmcs_host/linux
-I/opt/userland/host_applications/linux/apps/raspicam -I/opt/nanomsg/include -Winline -pipe -D_DEBUG -D_MATLABIO_
IO_wrapperCameraboard.c -o obj/IO_wrapperCameraboard.o
[Compiling] IO_wrapperArducamMultiAdapter.c
gcc -c -g -O0 -D_DEBUG -Wall -I/opt/userland -I/opt/userland/host_applications/linux/libs/bcm_host/include
-I/opt/userland/interface/vcos -I/opt/userland/interface/vcos/pthreads -I/opt/userland/interface/vmcs_host/linux
-I/opt/userland/host_applications/linux/apps/raspicam -I/opt/nanomsg/include -Winline -pipe -D_DEBUG -D_MATLABIO_
IO_wrapperArducamMultiAdapter.c -o obj/IO_wrapperArducamMultiAdapter.o
[Compiling] mw_wrapperCANChannel.c
gcc -c -g -O0 -D_DEBUG -Wall -I/opt/userland -I/opt/userland/host_applications/linux/libs/bcm_host/include
-I/opt/userland/interface/vcos -I/opt/userland/interface/vcos/pthreads -I/opt/userland/interface/vmcs_host/linux
-I/opt/userland/host_applications/linux/apps/raspicam -I/opt/nanomsg/include -Winline -pipe -D_DEBUG -D_MATLABIO_
mw_wrapperCANChannel.c -o obj/mw_wrapperCANChannel.o
[Compiling] LED.c
gcc -c -g -O0 -D_DEBUG -Wall -I/opt/userland -I/opt/userland/host_applications/linux/libs/bcm_host/include
-I/opt/userland/interface/vcos -I/opt/userland/interface/vcos/pthreads -I/opt/userland/interface/vmcs_host/linux
-I/opt/userland/host_applications/linux/apps/raspicam -I/opt/nanomsg/include -Winline -pipe -D_DEBUG -D_MATLABIO_ LED.c -o
obj/LED.o
[Compiling] picam.c
gcc -c -g -O0 -D_DEBUG -Wall -I/opt/userland -I/opt/userland/host_applications/linux/libs/bcm_host/include
-I/opt/userland/interface/vcos -I/opt/userland/interface/vcos/pthreads -I/opt/userland/interface/vmcs_host/linux
-I/opt/userland/host_applications/linux/apps/raspicam -I/opt/nanomsg/include -Winline -pipe -D_DEBUG -D_MATLABIO_ picam.c -o
obj/picam.o
[Compiling] arducamMultiAdapter.c
gcc -c -g -O0 -D_DEBUG -Wall -I/opt/userland -I/opt/userland/host_applications/linux/libs/bcm_host/include
-I/opt/userland/interface/vcos -I/opt/userland/interface/vcos/pthreads -I/opt/userland/interface/vmcs_host/linux
-I/opt/userland/host_applications/linux/apps/raspicam -I/opt/nanomsg/include -Winline -pipe -D_DEBUG -D_MATLABIO_
arducamMultiAdapter.c -o obj/arducamMultiAdapter.o
[Compiling] system.c
gcc -c -g -O0 -D_DEBUG -Wall -I/opt/userland -I/opt/userland/host_applications/linux/libs/bcm_host/include
-I/opt/userland/interface/vcos -I/opt/userland/interface/vcos/pthreads -I/opt/userland/interface/vmcs_host/linux
-I/opt/userland/host_applications/linux/apps/raspicam -I/opt/nanomsg/include -Winline -pipe -D_DEBUG -D_MATLABIO_ system.c -o
obj/system.o
[Compiling] IO_wrapperLED.c
gcc -c -g -O0 -D_DEBUG -Wall -I/opt/userland -I/opt/userland/host_applications/linux/libs/bcm_host/include
-I/opt/userland/interface/vcos -I/opt/userland/interface/vcos/pthreads -I/opt/userland/interface/vmcs_host/linux
-I/opt/userland/host_applications/linux/apps/raspicam -I/opt/nanomsg/include -Winline -pipe -D_DEBUG -D_MATLABIO_ IO_wrapperLED.c
-o obj/IO_wrapperLED.o
[Compiling] MW_digitalIO.c
gcc -c -g -O0 -D_DEBUG -Wall -I/opt/userland -I/opt/userland/host_applications/linux/libs/bcm_host/include
-I/opt/userland/interface/vcos -I/opt/userland/interface/vcos/pthreads -I/opt/userland/interface/vmcs_host/linux
-I/opt/userland/host_applications/linux/apps/raspicam -I/opt/nanomsg/include -Winline -pipe -D_DEBUG -D_MATLABIO_ MW_digitalIO.c
-o obj/MW_digitalIO.o
[Compiling] customFunction.c
gcc -c -g -O0 -D_DEBUG -Wall -I/opt/userland -I/opt/userland/host_applications/linux/libs/bcm_host/include
-I/opt/userland/interface/vcos -I/opt/userland/interface/vcos/pthreads -I/opt/userland/interface/vmcs_host/linux
-I/opt/userland/host_applications/linux/apps/raspicam -I/opt/nanomsg/include -Winline -pipe -D_DEBUG -D_MATLABIO_
customFunction.c -o obj/customFunction.o
[Compiling] servoRaspi.c
gcc -c -g -O0 -D_DEBUG -Wall -I/opt/userland -I/opt/userland/host_applications/linux/libs/bcm_host/include
-I/opt/userland/interface/vcos -I/opt/userland/interface/vcos/pthreads -I/opt/userland/interface/vmcs_host/linux
-I/opt/userland/host_applications/linux/apps/raspicam -I/opt/nanomsg/include -Winline -pipe -D_DEBUG -D_MATLABIO_ servoRaspi.c -o
obj/servoRaspi.o
[Compiling] IO_checksum.c
gcc -c -g -O0 -D_DEBUG -Wall -I/opt/userland -I/opt/userland/host_applications/linux/libs/bcm_host/include
-I/opt/userland/interface/vcos -I/opt/userland/interface/vcos/pthreads -I/opt/userland/interface/vmcs_host/linux
-I/opt/userland/host_applications/linux/apps/raspicam -I/opt/nanomsg/include -Winline -pipe -D_DEBUG -D_MATLABIO_ IO_checksum.c
-o obj/IO_checksum.o
[Compiling] IO_packet.c
gcc -c -g -O0 -D_DEBUG -Wall -I/opt/userland -I/opt/userland/host_applications/linux/libs/bcm_host/include
-I/opt/userland/interface/vcos -I/opt/userland/interface/vcos/pthreads -I/opt/userland/interface/vmcs_host/linux
-I/opt/userland/host_applications/linux/apps/raspicam -I/opt/nanomsg/include -Winline -pipe -D_DEBUG -D_MATLABIO_ IO_packet.c -o
obj/IO_packet.o
[Compiling] IO_standardperipherals.c
gcc -c -g -O0 -D_DEBUG -Wall -I/opt/userland -I/opt/userland/host_applications/linux/libs/bcm_host/include
-I/opt/userland/interface/vcos -I/opt/userland/interface/vcos/pthreads -I/opt/userland/interface/vmcs_host/linux
-I/opt/userland/host_applications/linux/apps/raspicam -I/opt/nanomsg/include -Winline -pipe -D_DEBUG -D_MATLABIO_
IO_standardperipherals.c -o obj/IO_standardperipherals.o
[Compiling] IO_wrapperI2C.c
gcc -c -g -O0 -D_DEBUG -Wall -I/opt/userland -I/opt/userland/host_applications/linux/libs/bcm_host/include
-I/opt/userland/interface/vcos -I/opt/userland/interface/vcos/pthreads -I/opt/userland/interface/vmcs_host/linux
-I/opt/userland/host_applications/linux/apps/raspicam -I/opt/nanomsg/include -Winline -pipe -D_DEBUG -D_MATLABIO_ IO_wrapperI2C.c
-o obj/IO_wrapperI2C.o
[Compiling] IO_wrapperPulseIn.c
gcc -c -g -O0 -D_DEBUG -Wall -I/opt/userland -I/opt/userland/host_applications/linux/libs/bcm_host/include
-I/opt/userland/interface/vcos -I/opt/userland/interface/vcos/pthreads -I/opt/userland/interface/vmcs_host/linux
-I/opt/userland/host_applications/linux/apps/raspicam -I/opt/nanomsg/include -Winline -pipe -D_DEBUG -D_MATLABIO_
IO_wrapperPulseIn.c -o obj/IO_wrapperPulseIn.o
[Compiling] IO_wrapperSCI.c
gcc -c -g -O0 -D_DEBUG -Wall -I/opt/userland -I/opt/userland/host_applications/linux/libs/bcm_host/include
-I/opt/userland/interface/vcos -I/opt/userland/interface/vcos/pthreads -I/opt/userland/interface/vmcs_host/linux
-I/opt/userland/host_applications/linux/apps/raspicam -I/opt/nanomsg/include -Winline -pipe -D_DEBUG -D_MATLABIO_ IO_wrapperSCI.c
-o obj/IO_wrapperSCI.o
[Compiling] PeripheralToHandle.c
gcc -c -g -O0 -D_DEBUG -Wall -I/opt/userland -I/opt/userland/host_applications/linux/libs/bcm_host/include
-I/opt/userland/interface/vcos -I/opt/userland/interface/vcos/pthreads -I/opt/userland/interface/vmcs_host/linux
-I/opt/userland/host_applications/linux/apps/raspicam -I/opt/nanomsg/include -Winline -pipe -D_DEBUG -D_MATLABIO_
PeripheralToHandle.c -o obj/PeripheralToHandle.o
[Compiling] IO_debug.c
gcc -c -g -O0 -D_DEBUG -Wall -I/opt/userland -I/opt/userland/host_applications/linux/libs/bcm_host/include
-I/opt/userland/interface/vcos -I/opt/userland/interface/vcos/pthreads -I/opt/userland/interface/vmcs_host/linux
-I/opt/userland/host_applications/linux/apps/raspicam -I/opt/nanomsg/include -Winline -pipe -D_DEBUG -D_MATLABIO_ IO_debug.c -o
obj/IO_debug.o
[Compiling] IO_server.c
gcc -c -g -O0 -D_DEBUG -Wall -I/opt/userland -I/opt/userland/host_applications/linux/libs/bcm_host/include
-I/opt/userland/interface/vcos -I/opt/userland/interface/vcos/pthreads -I/opt/userland/interface/vmcs_host/linux
-I/opt/userland/host_applications/linux/apps/raspicam -I/opt/nanomsg/include -Winline -pipe -D_DEBUG -D_MATLABIO_ IO_server.c -o
obj/IO_server.o
[Compiling] IO_utilities.c
gcc -c -g -O0 -D_DEBUG -Wall -I/opt/userland -I/opt/userland/host_applications/linux/libs/bcm_host/include
-I/opt/userland/interface/vcos -I/opt/userland/interface/vcos/pthreads -I/opt/userland/interface/vmcs_host/linux
-I/opt/userland/host_applications/linux/apps/raspicam -I/opt/nanomsg/include -Winline -pipe -D_DEBUG -D_MATLABIO_ IO_utilities.c
-o obj/IO_utilities.o
[Compiling] IO_wrapperDigitalIO.c
gcc -c -g -O0 -D_DEBUG -Wall -I/opt/userland -I/opt/userland/host_applications/linux/libs/bcm_host/include
-I/opt/userland/interface/vcos -I/opt/userland/interface/vcos/pthreads -I/opt/userland/interface/vmcs_host/linux
-I/opt/userland/host_applications/linux/apps/raspicam -I/opt/nanomsg/include -Winline -pipe -D_DEBUG -D_MATLABIO_
IO_wrapperDigitalIO.c -o obj/IO_wrapperDigitalIO.o
[Compiling] IO_wrapperPWM.c
gcc -c -g -O0 -D_DEBUG -Wall -I/opt/userland -I/opt/userland/host_applications/linux/libs/bcm_host/include
-I/opt/userland/interface/vcos -I/opt/userland/interface/vcos/pthreads -I/opt/userland/interface/vmcs_host/linux
-I/opt/userland/host_applications/linux/apps/raspicam -I/opt/nanomsg/include -Winline -pipe -D_DEBUG -D_MATLABIO_ IO_wrapperPWM.c
-o obj/IO_wrapperPWM.o
[Compiling] IO_wrapperSPI.c
gcc -c -g -O0 -D_DEBUG -Wall -I/opt/userland -I/opt/userland/host_applications/linux/libs/bcm_host/include
-I/opt/userland/interface/vcos -I/opt/userland/interface/vcos/pthreads -I/opt/userland/interface/vmcs_host/linux
-I/opt/userland/host_applications/linux/apps/raspicam -I/opt/nanomsg/include -Winline -pipe -D_DEBUG -D_MATLABIO_ IO_wrapperSPI.c
-o obj/IO_wrapperSPI.o
[Compiling] /opt/userland/host_applications/linux/apps/raspicam/RaspiCamControl.c
gcc -c -g -O0 -D_DEBUG -Wall -I/opt/userland -I/opt/userland/host_applications/linux/libs/bcm_host/include
-I/opt/userland/interface/vcos -I/opt/userland/interface/vcos/pthreads -I/opt/userland/interface/vmcs_host/linux
-I/opt/userland/host_applications/linux/apps/raspicam -I/opt/nanomsg/include -Winline -pipe -D_DEBUG -D_MATLABIO_
/opt/userland/host_applications/linux/apps/raspicam/RaspiCamControl.c -o obj/RaspiCamControl.o
[Compiling] /opt/userland/host_applications/linux/apps/raspicam/RaspiHelpers.c
gcc -c -g -O0 -D_DEBUG -Wall -I/opt/userland -I/opt/userland/host_applications/linux/libs/bcm_host/include
-I/opt/userland/interface/vcos -I/opt/userland/interface/vcos/pthreads -I/opt/userland/interface/vmcs_host/linux
-I/opt/userland/host_applications/linux/apps/raspicam -I/opt/nanomsg/include -Winline -pipe -D_DEBUG -D_MATLABIO_
/opt/userland/host_applications/linux/apps/raspicam/RaspiHelpers.c -o obj/RaspiHelpers.o
[Compiling] /opt/userland/host_applications/linux/apps/raspicam/RaspiPreview.c
gcc -c -g -O0 -D_DEBUG -Wall -I/opt/userland -I/opt/userland/host_applications/linux/libs/bcm_host/include
-I/opt/userland/interface/vcos -I/opt/userland/interface/vcos/pthreads -I/opt/userland/interface/vmcs_host/linux
-I/opt/userland/host_applications/linux/apps/raspicam -I/opt/nanomsg/include -Winline -pipe -D_DEBUG -D_MATLABIO_
/opt/userland/host_applications/linux/apps/raspicam/RaspiPreview.c -o obj/RaspiPreview.o
[Compiling] /opt/userland/host_applications/linux/apps/raspicam/RaspiCLI.c
gcc -c -g -O0 -D_DEBUG -Wall -I/opt/userland -I/opt/userland/host_applications/linux/libs/bcm_host/include
-I/opt/userland/interface/vcos -I/opt/userland/interface/vcos/pthreads -I/opt/userland/interface/vmcs_host/linux
-I/opt/userland/host_applications/linux/apps/raspicam -I/opt/nanomsg/include -Winline -pipe -D_DEBUG -D_MATLABIO_
/opt/userland/host_applications/linux/apps/raspicam/RaspiCLI.c -o obj/RaspiCLI.o
[Compiling] /opt/userland/host_applications/linux/apps/raspicam/RaspiCommonSettings.c
gcc -c -g -O0 -D_DEBUG -Wall -I/opt/userland -I/opt/userland/host_applications/linux/libs/bcm_host/include
-I/opt/userland/interface/vcos -I/opt/userland/interface/vcos/pthreads -I/opt/userland/interface/vmcs_host/linux
-I/opt/userland/host_applications/linux/apps/raspicam -I/opt/nanomsg/include -Winline -pipe -D_DEBUG -D_MATLABIO_
/opt/userland/host_applications/linux/apps/raspicam/RaspiCommonSettings.c -o obj/RaspiCommonSettings.o
[Compiling] frameBuffer.c
gcc -c -g -O0 -D_DEBUG -Wall -I/opt/userland -I/opt/userland/host_applications/linux/libs/bcm_host/include
-I/opt/userland/interface/vcos -I/opt/userland/interface/vcos/pthreads -I/opt/userland/interface/vmcs_host/linux
-I/opt/userland/host_applications/linux/apps/raspicam -I/opt/nanomsg/include -Winline -pipe -D_DEBUG -D_MATLABIO_ frameBuffer.c
-o obj/frameBuffer.o
[Compiling] frameBufferRaspi.c
gcc -c -g -O0 -D_DEBUG -Wall -I/opt/userland -I/opt/userland/host_applications/linux/libs/bcm_host/include
-I/opt/userland/interface/vcos -I/opt/userland/interface/vcos/pthreads -I/opt/userland/interface/vmcs_host/linux
-I/opt/userland/host_applications/linux/apps/raspicam -I/opt/nanomsg/include -Winline -pipe -D_DEBUG -D_MATLABIO_
frameBufferRaspi.c -o obj/frameBufferRaspi.o
[Compiling] joystick.c
gcc -c -g -O0 -D_DEBUG -Wall -I/opt/userland -I/opt/userland/host_applications/linux/libs/bcm_host/include
-I/opt/userland/interface/vcos -I/opt/userland/interface/vcos/pthreads -I/opt/userland/interface/vmcs_host/linux
-I/opt/userland/host_applications/linux/apps/raspicam -I/opt/nanomsg/include -Winline -pipe -D_DEBUG -D_MATLABIO_ joystick.c -o
obj/joystick.o
[Compiling] joystickRaspi.c
gcc -c -g -O0 -D_DEBUG -Wall -I/opt/userland -I/opt/userland/host_applications/linux/libs/bcm_host/include
-I/opt/userland/interface/vcos -I/opt/userland/interface/vcos/pthreads -I/opt/userland/interface/vmcs_host/linux
-I/opt/userland/host_applications/linux/apps/raspicam -I/opt/nanomsg/include -Winline -pipe -D_DEBUG -D_MATLABIO_ joystickRaspi.c
-o obj/joystickRaspi.o
[Compiling] runCommand.c
gcc -c -g -O0 -D_DEBUG -Wall -I/opt/userland -I/opt/userland/host_applications/linux/libs/bcm_host/include
-I/opt/userland/interface/vcos -I/opt/userland/interface/vcos/pthreads -I/opt/userland/interface/vmcs_host/linux
-I/opt/userland/host_applications/linux/apps/raspicam -I/opt/nanomsg/include -Winline -pipe -D_DEBUG -D_MATLABIO_ runCommand.c -o
obj/runCommand.o
echo [Linking]
[Linking]
make: Leaving directory ‘/opt/MATLAB/mw_server_v23.2.0’ >> r=raspi("192.168.137.128","jiang","raspberry")
### Updating Raspberry Pi I/O server…
### Connecting to board…
### Connected to 192.168.137.128…
### Creating server folder…
### Transferring source files…
### Building MATLAB I/O server…
Error executing command "make ONLY_MATLAB_IO=1 -C /opt/MATLAB/mw_server_v23.2.0 -f Makefile". Details:
STDERR: ‘writeReadSPI’:
IO_wrapperSPI.c:210:12: warning: passing argument 1 of ‘memcpy’ discards ‘const’ qualifier from pointer target type
[-Wdiscarded-qualifiers]
210 | memcpy(wrData, &payloadBufferRx[index], dataLength); // Copy data to be written to local buffer
| ^~~~~~
In file included from IO_include.h:18,
from PeripheralToHandle.h:13,
from IO_peripheralInclude.h:16,
from IO_wrapperSPI.h:15,
from IO_wrapperSPI.c:10:
/usr/include/string.h:43:39: note: expected ‘void * restrict’ but argument is of type ‘const uint8_T *’ {aka ‘const unsigned char
*’}
43 | extern void *memcpy (void *__restrict __dest, const void *__restrict __src,
| ~~~~~~~~~~~~~~~~~^~~~~~
IO_wrapperSPI.c:189:32: warning: unused variable ‘ctr’ [-Wunused-variable]
189 | uint32_T SPIBus,dataLength,ctr;
| ^~~
/opt/userland/host_applications/linux/apps/raspicam/RaspiHelpers.c: In function ‘print_app_details’:
/opt/userland/host_applications/linux/apps/raspicam/RaspiHelpers.c:69:57: warning: implicit declaration of function ‘basename’;
did you mean ‘rename’? [-Wimplicit-function-declaration]
69 | fprintf(fd, "n"%s" Camera App (commit %s%s)nn", basename(app_name), GIT_COMMIT_ID, TAINTED);
| ^~~~~~~~
| rename
/opt/userland/host_applications/linux/apps/raspicam/RaspiHelpers.c:69:22: warning: format ‘%s’ expects argument of type ‘char *’,
but argument 3 has type ‘int’ [-Wformat=]
69 | fprintf(fd, "n"%s" Camera App (commit %s%s)nn", basename(app_name), GIT_COMMIT_ID, TAINTED);
| ~^ ~~~~~~~~~~~~~~~~~~
| | |
| char * int
| %d
/opt/userland/host_applications/linux/apps/raspicam/RaspiCommonSettings.c: In function ‘raspicommonsettings_parse_cmdline’:
/opt/userland/host_applications/linux/apps/raspicam/RaspiCommonSettings.c:149:32: warning: implicit declaration of function
‘basename’; did you mean ‘rename’? [-Wimplicit-function-declaration]
149 | display_valid_parameters(basename(get_app_name()), app_help);
| ^~~~~~~~
| rename
/opt/userland/host_applications/linux/apps/raspicam/RaspiCommonSettings.c:149:32: warning: passing argument 1 of
‘display_valid_parameters’ makes pointer from integer without a cast [-Wint-conversion]
149 | display_valid_parameters(basename(get_app_name()), app_help);
| ^~~~~~~~~~~~~~~~~~~~~~~~
| |
| int
In file included from /opt/userland/host_applications/linux/apps/raspicam/RaspiCommonSettings.c:57:
/opt/userland/host_applications/linux/apps/raspicam/RaspiHelpers.h:32:37: note: expected ‘char *’ but argument is of type ‘int’
32 | void display_valid_parameters(char *name, void (*app_help)(char*));
| ~~~~~~^~~~
frameBuffer.c: In function ‘EXT_FRAMEBUFFER_INIT’:
frameBuffer.c:54:55: warning: comparison between pointer and zero character constant [-Wpointer-compare]
54 | for(ii=0;ii<100 & glob_buffer.gl_pathv[i] != ”;ii++)
| ^~
frameBuffer.c:54:31: note: did you mean to dereference the pointer?
54 | for(ii=0;ii<100 & glob_buffer.gl_pathv[i] != ”;ii++)
| ^
frameBuffer.c:54:24: warning: suggest parentheses around comparison in operand of ‘&’ [-Wparentheses]
54 | for(ii=0;ii<100 & glob_buffer.gl_pathv[i] != ”;ii++)
| ~~^~~~
frameBuffer.c: In function ‘EXT_FRAMEBUFFER_WRITEPIXEL’:
frameBuffer.c:80:9: warning: unused variable ‘ii’ [-Wunused-variable]
80 | int ii ;
| ^~
frameBuffer.c: In function ‘EXT_FRAMEBUFFER_DISPLAYIMAGE’:
frameBuffer.c:107:17: warning: suggest parentheses around comparison in operand of ‘&’ [-Wparentheses]
107 | for(ii=0; ii<100 & sh_fbname[ii] != ”; ii++)
| ~~^~~~
frameBuffer.c:105:10: warning: variable ‘fileName’ set but not used [-Wunused-but-set-variable]
105 | char fileName[100];
| ^~~~~~~~
frameBuffer.c:104:9: warning: unused variable ‘pxllocation’ [-Wunused-variable]
104 | int pxllocation=0;
| ^~~~~~~~~~~
joystick.c: In function ‘EXT_JOYSTICK_INIT’:
joystick.c:45:56: warning: comparison between pointer and zero character constant [-Wpointer-compare]
45 | for(ii=0; ii<100 & glob_buffer.gl_pathv[i] != ”; ii++)
| ^~
joystick.c:45:32: note: did you mean to dereference the pointer?
45 | for(ii=0; ii<100 & glob_buffer.gl_pathv[i] != ”; ii++)
| ^
joystick.c:45:25: warning: suggest parentheses around comparison in operand of ‘&’ [-Wparentheses]
45 | for(ii=0; ii<100 & glob_buffer.gl_pathv[i] != ”; ii++)
| ~~^~~~
joystick.c: In function ‘EXT_JOYSTICK_READ’:
joystick.c:82:17: warning: suggest parentheses around comparison in operand of ‘&’ [-Wparentheses]
82 | for(ii=0;(ii<100 & sh_evdevName[ii] != ”);ii++)
| ~~^~~~
/usr/bin/ld: cannot find -lmmal: No such file or directory
/usr/bin/ld: cannot find -lmmal_core: No such file or directory
/usr/bin/ld: cannot find -lmmal_util: No such file or directory
/usr/bin/ld: cannot find -lmmal_vc_client: No such file or directory
collect2: error: ld returned 1 exit status
make: *** [Makefile:95: build] Error 1
STDOUT: make: Entering directory ‘/opt/MATLAB/mw_server_v23.2.0’
[Compiling] IO_wrapperv4l2.c
gcc -c -g -O0 -D_DEBUG -Wall -I/opt/userland -I/opt/userland/host_applications/linux/libs/bcm_host/include
-I/opt/userland/interface/vcos -I/opt/userland/interface/vcos/pthreads -I/opt/userland/interface/vmcs_host/linux
-I/opt/userland/host_applications/linux/apps/raspicam -I/opt/nanomsg/include -Winline -pipe -D_DEBUG -D_MATLABIO_
IO_wrapperv4l2.c -o obj/IO_wrapperv4l2.o
[Compiling] MW_PWM.c
gcc -c -g -O0 -D_DEBUG -Wall -I/opt/userland -I/opt/userland/host_applications/linux/libs/bcm_host/include
-I/opt/userland/interface/vcos -I/opt/userland/interface/vcos/pthreads -I/opt/userland/interface/vmcs_host/linux
-I/opt/userland/host_applications/linux/apps/raspicam -I/opt/nanomsg/include -Winline -pipe -D_DEBUG -D_MATLABIO_ MW_PWM.c -o
obj/MW_PWM.o
[Compiling] MW_pigs.c
gcc -c -g -O0 -D_DEBUG -Wall -I/opt/userland -I/opt/userland/host_applications/linux/libs/bcm_host/include
-I/opt/userland/interface/vcos -I/opt/userland/interface/vcos/pthreads -I/opt/userland/interface/vmcs_host/linux
-I/opt/userland/host_applications/linux/apps/raspicam -I/opt/nanomsg/include -Winline -pipe -D_DEBUG -D_MATLABIO_ MW_pigs.c -o
obj/MW_pigs.o
[Compiling] sharedServer.c
gcc -c -g -O0 -D_DEBUG -Wall -I/opt/userland -I/opt/userland/host_applications/linux/libs/bcm_host/include
-I/opt/userland/interface/vcos -I/opt/userland/interface/vcos/pthreads -I/opt/userland/interface/vmcs_host/linux
-I/opt/userland/host_applications/linux/apps/raspicam -I/opt/nanomsg/include -Winline -pipe -D_DEBUG -D_MATLABIO_ sharedServer.c
-o obj/sharedServer.o
[Compiling] IO_wrapperCameraboard.c
gcc -c -g -O0 -D_DEBUG -Wall -I/opt/userland -I/opt/userland/host_applications/linux/libs/bcm_host/include
-I/opt/userland/interface/vcos -I/opt/userland/interface/vcos/pthreads -I/opt/userland/interface/vmcs_host/linux
-I/opt/userland/host_applications/linux/apps/raspicam -I/opt/nanomsg/include -Winline -pipe -D_DEBUG -D_MATLABIO_
IO_wrapperCameraboard.c -o obj/IO_wrapperCameraboard.o
[Compiling] IO_wrapperArducamMultiAdapter.c
gcc -c -g -O0 -D_DEBUG -Wall -I/opt/userland -I/opt/userland/host_applications/linux/libs/bcm_host/include
-I/opt/userland/interface/vcos -I/opt/userland/interface/vcos/pthreads -I/opt/userland/interface/vmcs_host/linux
-I/opt/userland/host_applications/linux/apps/raspicam -I/opt/nanomsg/include -Winline -pipe -D_DEBUG -D_MATLABIO_
IO_wrapperArducamMultiAdapter.c -o obj/IO_wrapperArducamMultiAdapter.o
[Compiling] mw_wrapperCANChannel.c
gcc -c -g -O0 -D_DEBUG -Wall -I/opt/userland -I/opt/userland/host_applications/linux/libs/bcm_host/include
-I/opt/userland/interface/vcos -I/opt/userland/interface/vcos/pthreads -I/opt/userland/interface/vmcs_host/linux
-I/opt/userland/host_applications/linux/apps/raspicam -I/opt/nanomsg/include -Winline -pipe -D_DEBUG -D_MATLABIO_
mw_wrapperCANChannel.c -o obj/mw_wrapperCANChannel.o
[Compiling] LED.c
gcc -c -g -O0 -D_DEBUG -Wall -I/opt/userland -I/opt/userland/host_applications/linux/libs/bcm_host/include
-I/opt/userland/interface/vcos -I/opt/userland/interface/vcos/pthreads -I/opt/userland/interface/vmcs_host/linux
-I/opt/userland/host_applications/linux/apps/raspicam -I/opt/nanomsg/include -Winline -pipe -D_DEBUG -D_MATLABIO_ LED.c -o
obj/LED.o
[Compiling] picam.c
gcc -c -g -O0 -D_DEBUG -Wall -I/opt/userland -I/opt/userland/host_applications/linux/libs/bcm_host/include
-I/opt/userland/interface/vcos -I/opt/userland/interface/vcos/pthreads -I/opt/userland/interface/vmcs_host/linux
-I/opt/userland/host_applications/linux/apps/raspicam -I/opt/nanomsg/include -Winline -pipe -D_DEBUG -D_MATLABIO_ picam.c -o
obj/picam.o
[Compiling] arducamMultiAdapter.c
gcc -c -g -O0 -D_DEBUG -Wall -I/opt/userland -I/opt/userland/host_applications/linux/libs/bcm_host/include
-I/opt/userland/interface/vcos -I/opt/userland/interface/vcos/pthreads -I/opt/userland/interface/vmcs_host/linux
-I/opt/userland/host_applications/linux/apps/raspicam -I/opt/nanomsg/include -Winline -pipe -D_DEBUG -D_MATLABIO_
arducamMultiAdapter.c -o obj/arducamMultiAdapter.o
[Compiling] system.c
gcc -c -g -O0 -D_DEBUG -Wall -I/opt/userland -I/opt/userland/host_applications/linux/libs/bcm_host/include
-I/opt/userland/interface/vcos -I/opt/userland/interface/vcos/pthreads -I/opt/userland/interface/vmcs_host/linux
-I/opt/userland/host_applications/linux/apps/raspicam -I/opt/nanomsg/include -Winline -pipe -D_DEBUG -D_MATLABIO_ system.c -o
obj/system.o
[Compiling] IO_wrapperLED.c
gcc -c -g -O0 -D_DEBUG -Wall -I/opt/userland -I/opt/userland/host_applications/linux/libs/bcm_host/include
-I/opt/userland/interface/vcos -I/opt/userland/interface/vcos/pthreads -I/opt/userland/interface/vmcs_host/linux
-I/opt/userland/host_applications/linux/apps/raspicam -I/opt/nanomsg/include -Winline -pipe -D_DEBUG -D_MATLABIO_ IO_wrapperLED.c
-o obj/IO_wrapperLED.o
[Compiling] MW_digitalIO.c
gcc -c -g -O0 -D_DEBUG -Wall -I/opt/userland -I/opt/userland/host_applications/linux/libs/bcm_host/include
-I/opt/userland/interface/vcos -I/opt/userland/interface/vcos/pthreads -I/opt/userland/interface/vmcs_host/linux
-I/opt/userland/host_applications/linux/apps/raspicam -I/opt/nanomsg/include -Winline -pipe -D_DEBUG -D_MATLABIO_ MW_digitalIO.c
-o obj/MW_digitalIO.o
[Compiling] customFunction.c
gcc -c -g -O0 -D_DEBUG -Wall -I/opt/userland -I/opt/userland/host_applications/linux/libs/bcm_host/include
-I/opt/userland/interface/vcos -I/opt/userland/interface/vcos/pthreads -I/opt/userland/interface/vmcs_host/linux
-I/opt/userland/host_applications/linux/apps/raspicam -I/opt/nanomsg/include -Winline -pipe -D_DEBUG -D_MATLABIO_
customFunction.c -o obj/customFunction.o
[Compiling] servoRaspi.c
gcc -c -g -O0 -D_DEBUG -Wall -I/opt/userland -I/opt/userland/host_applications/linux/libs/bcm_host/include
-I/opt/userland/interface/vcos -I/opt/userland/interface/vcos/pthreads -I/opt/userland/interface/vmcs_host/linux
-I/opt/userland/host_applications/linux/apps/raspicam -I/opt/nanomsg/include -Winline -pipe -D_DEBUG -D_MATLABIO_ servoRaspi.c -o
obj/servoRaspi.o
[Compiling] IO_checksum.c
gcc -c -g -O0 -D_DEBUG -Wall -I/opt/userland -I/opt/userland/host_applications/linux/libs/bcm_host/include
-I/opt/userland/interface/vcos -I/opt/userland/interface/vcos/pthreads -I/opt/userland/interface/vmcs_host/linux
-I/opt/userland/host_applications/linux/apps/raspicam -I/opt/nanomsg/include -Winline -pipe -D_DEBUG -D_MATLABIO_ IO_checksum.c
-o obj/IO_checksum.o
[Compiling] IO_packet.c
gcc -c -g -O0 -D_DEBUG -Wall -I/opt/userland -I/opt/userland/host_applications/linux/libs/bcm_host/include
-I/opt/userland/interface/vcos -I/opt/userland/interface/vcos/pthreads -I/opt/userland/interface/vmcs_host/linux
-I/opt/userland/host_applications/linux/apps/raspicam -I/opt/nanomsg/include -Winline -pipe -D_DEBUG -D_MATLABIO_ IO_packet.c -o
obj/IO_packet.o
[Compiling] IO_standardperipherals.c
gcc -c -g -O0 -D_DEBUG -Wall -I/opt/userland -I/opt/userland/host_applications/linux/libs/bcm_host/include
-I/opt/userland/interface/vcos -I/opt/userland/interface/vcos/pthreads -I/opt/userland/interface/vmcs_host/linux
-I/opt/userland/host_applications/linux/apps/raspicam -I/opt/nanomsg/include -Winline -pipe -D_DEBUG -D_MATLABIO_
IO_standardperipherals.c -o obj/IO_standardperipherals.o
[Compiling] IO_wrapperI2C.c
gcc -c -g -O0 -D_DEBUG -Wall -I/opt/userland -I/opt/userland/host_applications/linux/libs/bcm_host/include
-I/opt/userland/interface/vcos -I/opt/userland/interface/vcos/pthreads -I/opt/userland/interface/vmcs_host/linux
-I/opt/userland/host_applications/linux/apps/raspicam -I/opt/nanomsg/include -Winline -pipe -D_DEBUG -D_MATLABIO_ IO_wrapperI2C.c
-o obj/IO_wrapperI2C.o
[Compiling] IO_wrapperPulseIn.c
gcc -c -g -O0 -D_DEBUG -Wall -I/opt/userland -I/opt/userland/host_applications/linux/libs/bcm_host/include
-I/opt/userland/interface/vcos -I/opt/userland/interface/vcos/pthreads -I/opt/userland/interface/vmcs_host/linux
-I/opt/userland/host_applications/linux/apps/raspicam -I/opt/nanomsg/include -Winline -pipe -D_DEBUG -D_MATLABIO_
IO_wrapperPulseIn.c -o obj/IO_wrapperPulseIn.o
[Compiling] IO_wrapperSCI.c
gcc -c -g -O0 -D_DEBUG -Wall -I/opt/userland -I/opt/userland/host_applications/linux/libs/bcm_host/include
-I/opt/userland/interface/vcos -I/opt/userland/interface/vcos/pthreads -I/opt/userland/interface/vmcs_host/linux
-I/opt/userland/host_applications/linux/apps/raspicam -I/opt/nanomsg/include -Winline -pipe -D_DEBUG -D_MATLABIO_ IO_wrapperSCI.c
-o obj/IO_wrapperSCI.o
[Compiling] PeripheralToHandle.c
gcc -c -g -O0 -D_DEBUG -Wall -I/opt/userland -I/opt/userland/host_applications/linux/libs/bcm_host/include
-I/opt/userland/interface/vcos -I/opt/userland/interface/vcos/pthreads -I/opt/userland/interface/vmcs_host/linux
-I/opt/userland/host_applications/linux/apps/raspicam -I/opt/nanomsg/include -Winline -pipe -D_DEBUG -D_MATLABIO_
PeripheralToHandle.c -o obj/PeripheralToHandle.o
[Compiling] IO_debug.c
gcc -c -g -O0 -D_DEBUG -Wall -I/opt/userland -I/opt/userland/host_applications/linux/libs/bcm_host/include
-I/opt/userland/interface/vcos -I/opt/userland/interface/vcos/pthreads -I/opt/userland/interface/vmcs_host/linux
-I/opt/userland/host_applications/linux/apps/raspicam -I/opt/nanomsg/include -Winline -pipe -D_DEBUG -D_MATLABIO_ IO_debug.c -o
obj/IO_debug.o
[Compiling] IO_server.c
gcc -c -g -O0 -D_DEBUG -Wall -I/opt/userland -I/opt/userland/host_applications/linux/libs/bcm_host/include
-I/opt/userland/interface/vcos -I/opt/userland/interface/vcos/pthreads -I/opt/userland/interface/vmcs_host/linux
-I/opt/userland/host_applications/linux/apps/raspicam -I/opt/nanomsg/include -Winline -pipe -D_DEBUG -D_MATLABIO_ IO_server.c -o
obj/IO_server.o
[Compiling] IO_utilities.c
gcc -c -g -O0 -D_DEBUG -Wall -I/opt/userland -I/opt/userland/host_applications/linux/libs/bcm_host/include
-I/opt/userland/interface/vcos -I/opt/userland/interface/vcos/pthreads -I/opt/userland/interface/vmcs_host/linux
-I/opt/userland/host_applications/linux/apps/raspicam -I/opt/nanomsg/include -Winline -pipe -D_DEBUG -D_MATLABIO_ IO_utilities.c
-o obj/IO_utilities.o
[Compiling] IO_wrapperDigitalIO.c
gcc -c -g -O0 -D_DEBUG -Wall -I/opt/userland -I/opt/userland/host_applications/linux/libs/bcm_host/include
-I/opt/userland/interface/vcos -I/opt/userland/interface/vcos/pthreads -I/opt/userland/interface/vmcs_host/linux
-I/opt/userland/host_applications/linux/apps/raspicam -I/opt/nanomsg/include -Winline -pipe -D_DEBUG -D_MATLABIO_
IO_wrapperDigitalIO.c -o obj/IO_wrapperDigitalIO.o
[Compiling] IO_wrapperPWM.c
gcc -c -g -O0 -D_DEBUG -Wall -I/opt/userland -I/opt/userland/host_applications/linux/libs/bcm_host/include
-I/opt/userland/interface/vcos -I/opt/userland/interface/vcos/pthreads -I/opt/userland/interface/vmcs_host/linux
-I/opt/userland/host_applications/linux/apps/raspicam -I/opt/nanomsg/include -Winline -pipe -D_DEBUG -D_MATLABIO_ IO_wrapperPWM.c
-o obj/IO_wrapperPWM.o
[Compiling] IO_wrapperSPI.c
gcc -c -g -O0 -D_DEBUG -Wall -I/opt/userland -I/opt/userland/host_applications/linux/libs/bcm_host/include
-I/opt/userland/interface/vcos -I/opt/userland/interface/vcos/pthreads -I/opt/userland/interface/vmcs_host/linux
-I/opt/userland/host_applications/linux/apps/raspicam -I/opt/nanomsg/include -Winline -pipe -D_DEBUG -D_MATLABIO_ IO_wrapperSPI.c
-o obj/IO_wrapperSPI.o
[Compiling] /opt/userland/host_applications/linux/apps/raspicam/RaspiCamControl.c
gcc -c -g -O0 -D_DEBUG -Wall -I/opt/userland -I/opt/userland/host_applications/linux/libs/bcm_host/include
-I/opt/userland/interface/vcos -I/opt/userland/interface/vcos/pthreads -I/opt/userland/interface/vmcs_host/linux
-I/opt/userland/host_applications/linux/apps/raspicam -I/opt/nanomsg/include -Winline -pipe -D_DEBUG -D_MATLABIO_
/opt/userland/host_applications/linux/apps/raspicam/RaspiCamControl.c -o obj/RaspiCamControl.o
[Compiling] /opt/userland/host_applications/linux/apps/raspicam/RaspiHelpers.c
gcc -c -g -O0 -D_DEBUG -Wall -I/opt/userland -I/opt/userland/host_applications/linux/libs/bcm_host/include
-I/opt/userland/interface/vcos -I/opt/userland/interface/vcos/pthreads -I/opt/userland/interface/vmcs_host/linux
-I/opt/userland/host_applications/linux/apps/raspicam -I/opt/nanomsg/include -Winline -pipe -D_DEBUG -D_MATLABIO_
/opt/userland/host_applications/linux/apps/raspicam/RaspiHelpers.c -o obj/RaspiHelpers.o
[Compiling] /opt/userland/host_applications/linux/apps/raspicam/RaspiPreview.c
gcc -c -g -O0 -D_DEBUG -Wall -I/opt/userland -I/opt/userland/host_applications/linux/libs/bcm_host/include
-I/opt/userland/interface/vcos -I/opt/userland/interface/vcos/pthreads -I/opt/userland/interface/vmcs_host/linux
-I/opt/userland/host_applications/linux/apps/raspicam -I/opt/nanomsg/include -Winline -pipe -D_DEBUG -D_MATLABIO_
/opt/userland/host_applications/linux/apps/raspicam/RaspiPreview.c -o obj/RaspiPreview.o
[Compiling] /opt/userland/host_applications/linux/apps/raspicam/RaspiCLI.c
gcc -c -g -O0 -D_DEBUG -Wall -I/opt/userland -I/opt/userland/host_applications/linux/libs/bcm_host/include
-I/opt/userland/interface/vcos -I/opt/userland/interface/vcos/pthreads -I/opt/userland/interface/vmcs_host/linux
-I/opt/userland/host_applications/linux/apps/raspicam -I/opt/nanomsg/include -Winline -pipe -D_DEBUG -D_MATLABIO_
/opt/userland/host_applications/linux/apps/raspicam/RaspiCLI.c -o obj/RaspiCLI.o
[Compiling] /opt/userland/host_applications/linux/apps/raspicam/RaspiCommonSettings.c
gcc -c -g -O0 -D_DEBUG -Wall -I/opt/userland -I/opt/userland/host_applications/linux/libs/bcm_host/include
-I/opt/userland/interface/vcos -I/opt/userland/interface/vcos/pthreads -I/opt/userland/interface/vmcs_host/linux
-I/opt/userland/host_applications/linux/apps/raspicam -I/opt/nanomsg/include -Winline -pipe -D_DEBUG -D_MATLABIO_
/opt/userland/host_applications/linux/apps/raspicam/RaspiCommonSettings.c -o obj/RaspiCommonSettings.o
[Compiling] frameBuffer.c
gcc -c -g -O0 -D_DEBUG -Wall -I/opt/userland -I/opt/userland/host_applications/linux/libs/bcm_host/include
-I/opt/userland/interface/vcos -I/opt/userland/interface/vcos/pthreads -I/opt/userland/interface/vmcs_host/linux
-I/opt/userland/host_applications/linux/apps/raspicam -I/opt/nanomsg/include -Winline -pipe -D_DEBUG -D_MATLABIO_ frameBuffer.c
-o obj/frameBuffer.o
[Compiling] frameBufferRaspi.c
gcc -c -g -O0 -D_DEBUG -Wall -I/opt/userland -I/opt/userland/host_applications/linux/libs/bcm_host/include
-I/opt/userland/interface/vcos -I/opt/userland/interface/vcos/pthreads -I/opt/userland/interface/vmcs_host/linux
-I/opt/userland/host_applications/linux/apps/raspicam -I/opt/nanomsg/include -Winline -pipe -D_DEBUG -D_MATLABIO_
frameBufferRaspi.c -o obj/frameBufferRaspi.o
[Compiling] joystick.c
gcc -c -g -O0 -D_DEBUG -Wall -I/opt/userland -I/opt/userland/host_applications/linux/libs/bcm_host/include
-I/opt/userland/interface/vcos -I/opt/userland/interface/vcos/pthreads -I/opt/userland/interface/vmcs_host/linux
-I/opt/userland/host_applications/linux/apps/raspicam -I/opt/nanomsg/include -Winline -pipe -D_DEBUG -D_MATLABIO_ joystick.c -o
obj/joystick.o
[Compiling] joystickRaspi.c
gcc -c -g -O0 -D_DEBUG -Wall -I/opt/userland -I/opt/userland/host_applications/linux/libs/bcm_host/include
-I/opt/userland/interface/vcos -I/opt/userland/interface/vcos/pthreads -I/opt/userland/interface/vmcs_host/linux
-I/opt/userland/host_applications/linux/apps/raspicam -I/opt/nanomsg/include -Winline -pipe -D_DEBUG -D_MATLABIO_ joystickRaspi.c
-o obj/joystickRaspi.o
[Compiling] runCommand.c
gcc -c -g -O0 -D_DEBUG -Wall -I/opt/userland -I/opt/userland/host_applications/linux/libs/bcm_host/include
-I/opt/userland/interface/vcos -I/opt/userland/interface/vcos/pthreads -I/opt/userland/interface/vmcs_host/linux
-I/opt/userland/host_applications/linux/apps/raspicam -I/opt/nanomsg/include -Winline -pipe -D_DEBUG -D_MATLABIO_ runCommand.c -o
obj/runCommand.o
echo [Linking]
[Linking]
make: Leaving directory ‘/opt/MATLAB/mw_server_v23.2.0’ raspberry, matlab2023b MATLAB Answers — New Questions
Computing Euler Angles from MoCap Markers 3D Data
I have obtained 3D (x,y,z) data from a Motion Capture (MoCap) system using markers placed on the subject’s head and chin. The data is structured in the following format. I need to compute the Euler angles (yaw, pitch, and roll). Any assistanse in this matter would be greatly appreciated.
headFL = [data.HeadFL_X, data.HeadFL_Y, data.HeadFL_Z];
headFR = [data.HeadFR_X, data.HeadFR_Y, data.HeadFR_Z];
headBL = [data.HeadBL_X, data.HeadBL_Y, data.HeadBL_Z];
headBR = [data.HeadBR_X, data.HeadBR_Y, data.HeadBR_Z];
chin = [data.Chin_X, data.Chin_Y, data.Chin_Z];
headFL = [-97.507,-105.897,1594.74]
headFR = [-186.455,-9.66,1609.556]
headBL = [20.236,-15.579,1544.697]
headBR = [-86.745, 98.811,1557.386]
Chin = [-169.193,-74.004,1431.651]I have obtained 3D (x,y,z) data from a Motion Capture (MoCap) system using markers placed on the subject’s head and chin. The data is structured in the following format. I need to compute the Euler angles (yaw, pitch, and roll). Any assistanse in this matter would be greatly appreciated.
headFL = [data.HeadFL_X, data.HeadFL_Y, data.HeadFL_Z];
headFR = [data.HeadFR_X, data.HeadFR_Y, data.HeadFR_Z];
headBL = [data.HeadBL_X, data.HeadBL_Y, data.HeadBL_Z];
headBR = [data.HeadBR_X, data.HeadBR_Y, data.HeadBR_Z];
chin = [data.Chin_X, data.Chin_Y, data.Chin_Z];
headFL = [-97.507,-105.897,1594.74]
headFR = [-186.455,-9.66,1609.556]
headBL = [20.236,-15.579,1544.697]
headBR = [-86.745, 98.811,1557.386]
Chin = [-169.193,-74.004,1431.651] I have obtained 3D (x,y,z) data from a Motion Capture (MoCap) system using markers placed on the subject’s head and chin. The data is structured in the following format. I need to compute the Euler angles (yaw, pitch, and roll). Any assistanse in this matter would be greatly appreciated.
headFL = [data.HeadFL_X, data.HeadFL_Y, data.HeadFL_Z];
headFR = [data.HeadFR_X, data.HeadFR_Y, data.HeadFR_Z];
headBL = [data.HeadBL_X, data.HeadBL_Y, data.HeadBL_Z];
headBR = [data.HeadBR_X, data.HeadBR_Y, data.HeadBR_Z];
chin = [data.Chin_X, data.Chin_Y, data.Chin_Z];
headFL = [-97.507,-105.897,1594.74]
headFR = [-186.455,-9.66,1609.556]
headBL = [20.236,-15.579,1544.697]
headBR = [-86.745, 98.811,1557.386]
Chin = [-169.193,-74.004,1431.651] transferred MATLAB Answers — New Questions
How to write a point’s coordinates
How can I write coordinates of my extrema on a figure?
I tried using "text" command but I stiil can’t deal with the problemHow can I write coordinates of my extrema on a figure?
I tried using "text" command but I stiil can’t deal with the problem How can I write coordinates of my extrema on a figure?
I tried using "text" command but I stiil can’t deal with the problem coordinates-figure-write, coordinates-figure-write-plot, coordinates_figure_write_plot, coordinates_figure_write, plot MATLAB Answers — New Questions
how mixing pressure Pm is calculated in gas ejector model of Matlab
how mixing pressure Pm is calculated in gas ejector model of Matlabhow mixing pressure Pm is calculated in gas ejector model of Matlab how mixing pressure Pm is calculated in gas ejector model of Matlab simulink, gas ejector model MATLAB Answers — New Questions
Invalid training data Predictors must be a N-by-1 cell array of sequences
% Reshape training data for LSTM input and output
num_features = size(X_train, 2);
num_samples_per_day = 24; % Number of hours in a day
num_days_train = size(X_train, 1) / num_samples_per_day;
X_train_reshaped = cell(num_days_train, 1);
y_train_reshaped = cell(num_days_train, 1);
for a = 1:num_days_train
start_idx = (a – 1) * num_samples_per_day + 1;
end_idx = a * num_samples_per_day;
% Extract data for the current day
current_day_data = X_train(start_idx:end_idx, :);
current_day_target = y_train(start_idx:end_idx);
% Reshape data into a cell array of matrices [num_features x num_samples_per_day]
reshaped_data = num2cell(current_day_data’, 1);
X_train_reshaped{a} = reshaped_data;
% Reshape target values into a cell array of column vectors
reshaped_target = reshape(current_day_target, [], 1);
y_train_reshaped{a} = reshaped_target;
end
% Reshape validation data for LSTM input
num_days_val = size(X_val, 1) / num_samples_per_day;
X_val_reshaped = cell(num_days_val, 1);
y_val_reshaped = cell(num_days_val, 1);
for b = 1:num_days_val
start_idx = (b – 1) * num_samples_per_day + 1;
end_idx = b * num_samples_per_day;
% Extract data for the current day
current_day_data = X_val(start_idx:end_idx, :);
current_day_target = y_val(start_idx:end_idx);
% Reshape data into a matrix [num_features x num_samples_per_day]
reshaped_data = current_day_data’;
% Reshape target values into a column vector
reshaped_target = current_day_target’;
% Store reshaped data and target for the current day
X_val_reshaped{b} = reshaped_data;
y_val_reshaped{b} = reshaped_target;
end
% Reshape test data for LSTM input
num_days_test = size(X_test, 1) / num_samples_per_day;
X_test_reshaped = cell(num_days_test, 1);
for c = 1:num_days_test
start_idx = (c – 1) * num_samples_per_day + 1;
end_idx = c * num_samples_per_day;
% Extract data for the current day
current_day_data = X_test(start_idx:end_idx, :);
% Reshape data into a matrix [num_features x num_samples_per_day]
reshaped_data = current_day_data’;
% Store reshaped data for the current day
X_test_reshaped{c} = reshaped_data;
end
% Define hyperparameters for grid search
hidden_layers = [1, 2, 3];
num_hidden_units_range = [24, 48, 96, 192];
dropout_rates = [0.1, 0.2, 0.3, 0.4, 0.5];
learning_rates = [0.05, 0.01, 0.005, 0.001, 0.0005];
optimization_solvers_list = {‘adam’, ‘sgdm’, ‘rmsprop’};
num_epochs_range = [50, 100, 150, 200, 250];
% Build LSTM model
layers = [
sequenceInputLayer(num_features)
];
for m = 1:num_layers
layers = [
layers
lstmLayer(num_units, ‘OutputMode’, ‘sequence’)
dropoutLayer(dropout_rate)
];
end
% Connect the last LSTM layer to a fully connected layer
layers = [
layers
fullyConnectedLayer(num_units)
dropoutLayer(dropout_rate)
fullyConnectedLayer(24) % Output layer with 24 units for 24-hour GHI forecasting
regressionLayer % Output layer for regression tasks
];
% Set options for training
options = trainingOptions(optimizer, …
‘MaxEpochs’, num_epochs, …
‘MiniBatchSize’, 64, …
‘InitialLearnRate’, learning_rate, …
‘LearnRateSchedule’, ‘piecewise’, …
‘LearnRateDropPeriod’, 50, …
‘LearnRateDropFactor’, 0.1, …
‘ValidationData’, {X_val_reshaped, y_val_reshaped}, …
‘ValidationFrequency’, 10, …
‘ValidationPatience’, 20, …
‘Verbose’, 0, …
‘Plots’, ‘training-progress’);
% Train the LSTM model
lstm_model = trainNetwork(X_train_reshaped, y_train_reshaped, layers, options);
% Predict GHI using the trained model on validation data
y_pred_val = predict(lstm_model, X_val_reshaped);
% Denormalize predictions
y_pred_denormalized = y_pred_val * (max(features.GHI) – min(features.GHI)) + min(features.GHI);
% Calculate evaluation metrics
rmse_val = calculate_rmse(y_val, y_pred_val_denormalized);
mae_val = calculate_mae(y_val, y_pred_val_denormalized);
end
Error using trainNetwork (line 184)
Invalid training data. Predictors must be a N-by-1 cell array of sequences, where N is the number of sequences. All
sequences must have the same feature dimension and at least one time step.% Reshape training data for LSTM input and output
num_features = size(X_train, 2);
num_samples_per_day = 24; % Number of hours in a day
num_days_train = size(X_train, 1) / num_samples_per_day;
X_train_reshaped = cell(num_days_train, 1);
y_train_reshaped = cell(num_days_train, 1);
for a = 1:num_days_train
start_idx = (a – 1) * num_samples_per_day + 1;
end_idx = a * num_samples_per_day;
% Extract data for the current day
current_day_data = X_train(start_idx:end_idx, :);
current_day_target = y_train(start_idx:end_idx);
% Reshape data into a cell array of matrices [num_features x num_samples_per_day]
reshaped_data = num2cell(current_day_data’, 1);
X_train_reshaped{a} = reshaped_data;
% Reshape target values into a cell array of column vectors
reshaped_target = reshape(current_day_target, [], 1);
y_train_reshaped{a} = reshaped_target;
end
% Reshape validation data for LSTM input
num_days_val = size(X_val, 1) / num_samples_per_day;
X_val_reshaped = cell(num_days_val, 1);
y_val_reshaped = cell(num_days_val, 1);
for b = 1:num_days_val
start_idx = (b – 1) * num_samples_per_day + 1;
end_idx = b * num_samples_per_day;
% Extract data for the current day
current_day_data = X_val(start_idx:end_idx, :);
current_day_target = y_val(start_idx:end_idx);
% Reshape data into a matrix [num_features x num_samples_per_day]
reshaped_data = current_day_data’;
% Reshape target values into a column vector
reshaped_target = current_day_target’;
% Store reshaped data and target for the current day
X_val_reshaped{b} = reshaped_data;
y_val_reshaped{b} = reshaped_target;
end
% Reshape test data for LSTM input
num_days_test = size(X_test, 1) / num_samples_per_day;
X_test_reshaped = cell(num_days_test, 1);
for c = 1:num_days_test
start_idx = (c – 1) * num_samples_per_day + 1;
end_idx = c * num_samples_per_day;
% Extract data for the current day
current_day_data = X_test(start_idx:end_idx, :);
% Reshape data into a matrix [num_features x num_samples_per_day]
reshaped_data = current_day_data’;
% Store reshaped data for the current day
X_test_reshaped{c} = reshaped_data;
end
% Define hyperparameters for grid search
hidden_layers = [1, 2, 3];
num_hidden_units_range = [24, 48, 96, 192];
dropout_rates = [0.1, 0.2, 0.3, 0.4, 0.5];
learning_rates = [0.05, 0.01, 0.005, 0.001, 0.0005];
optimization_solvers_list = {‘adam’, ‘sgdm’, ‘rmsprop’};
num_epochs_range = [50, 100, 150, 200, 250];
% Build LSTM model
layers = [
sequenceInputLayer(num_features)
];
for m = 1:num_layers
layers = [
layers
lstmLayer(num_units, ‘OutputMode’, ‘sequence’)
dropoutLayer(dropout_rate)
];
end
% Connect the last LSTM layer to a fully connected layer
layers = [
layers
fullyConnectedLayer(num_units)
dropoutLayer(dropout_rate)
fullyConnectedLayer(24) % Output layer with 24 units for 24-hour GHI forecasting
regressionLayer % Output layer for regression tasks
];
% Set options for training
options = trainingOptions(optimizer, …
‘MaxEpochs’, num_epochs, …
‘MiniBatchSize’, 64, …
‘InitialLearnRate’, learning_rate, …
‘LearnRateSchedule’, ‘piecewise’, …
‘LearnRateDropPeriod’, 50, …
‘LearnRateDropFactor’, 0.1, …
‘ValidationData’, {X_val_reshaped, y_val_reshaped}, …
‘ValidationFrequency’, 10, …
‘ValidationPatience’, 20, …
‘Verbose’, 0, …
‘Plots’, ‘training-progress’);
% Train the LSTM model
lstm_model = trainNetwork(X_train_reshaped, y_train_reshaped, layers, options);
% Predict GHI using the trained model on validation data
y_pred_val = predict(lstm_model, X_val_reshaped);
% Denormalize predictions
y_pred_denormalized = y_pred_val * (max(features.GHI) – min(features.GHI)) + min(features.GHI);
% Calculate evaluation metrics
rmse_val = calculate_rmse(y_val, y_pred_val_denormalized);
mae_val = calculate_mae(y_val, y_pred_val_denormalized);
end
Error using trainNetwork (line 184)
Invalid training data. Predictors must be a N-by-1 cell array of sequences, where N is the number of sequences. All
sequences must have the same feature dimension and at least one time step. % Reshape training data for LSTM input and output
num_features = size(X_train, 2);
num_samples_per_day = 24; % Number of hours in a day
num_days_train = size(X_train, 1) / num_samples_per_day;
X_train_reshaped = cell(num_days_train, 1);
y_train_reshaped = cell(num_days_train, 1);
for a = 1:num_days_train
start_idx = (a – 1) * num_samples_per_day + 1;
end_idx = a * num_samples_per_day;
% Extract data for the current day
current_day_data = X_train(start_idx:end_idx, :);
current_day_target = y_train(start_idx:end_idx);
% Reshape data into a cell array of matrices [num_features x num_samples_per_day]
reshaped_data = num2cell(current_day_data’, 1);
X_train_reshaped{a} = reshaped_data;
% Reshape target values into a cell array of column vectors
reshaped_target = reshape(current_day_target, [], 1);
y_train_reshaped{a} = reshaped_target;
end
% Reshape validation data for LSTM input
num_days_val = size(X_val, 1) / num_samples_per_day;
X_val_reshaped = cell(num_days_val, 1);
y_val_reshaped = cell(num_days_val, 1);
for b = 1:num_days_val
start_idx = (b – 1) * num_samples_per_day + 1;
end_idx = b * num_samples_per_day;
% Extract data for the current day
current_day_data = X_val(start_idx:end_idx, :);
current_day_target = y_val(start_idx:end_idx);
% Reshape data into a matrix [num_features x num_samples_per_day]
reshaped_data = current_day_data’;
% Reshape target values into a column vector
reshaped_target = current_day_target’;
% Store reshaped data and target for the current day
X_val_reshaped{b} = reshaped_data;
y_val_reshaped{b} = reshaped_target;
end
% Reshape test data for LSTM input
num_days_test = size(X_test, 1) / num_samples_per_day;
X_test_reshaped = cell(num_days_test, 1);
for c = 1:num_days_test
start_idx = (c – 1) * num_samples_per_day + 1;
end_idx = c * num_samples_per_day;
% Extract data for the current day
current_day_data = X_test(start_idx:end_idx, :);
% Reshape data into a matrix [num_features x num_samples_per_day]
reshaped_data = current_day_data’;
% Store reshaped data for the current day
X_test_reshaped{c} = reshaped_data;
end
% Define hyperparameters for grid search
hidden_layers = [1, 2, 3];
num_hidden_units_range = [24, 48, 96, 192];
dropout_rates = [0.1, 0.2, 0.3, 0.4, 0.5];
learning_rates = [0.05, 0.01, 0.005, 0.001, 0.0005];
optimization_solvers_list = {‘adam’, ‘sgdm’, ‘rmsprop’};
num_epochs_range = [50, 100, 150, 200, 250];
% Build LSTM model
layers = [
sequenceInputLayer(num_features)
];
for m = 1:num_layers
layers = [
layers
lstmLayer(num_units, ‘OutputMode’, ‘sequence’)
dropoutLayer(dropout_rate)
];
end
% Connect the last LSTM layer to a fully connected layer
layers = [
layers
fullyConnectedLayer(num_units)
dropoutLayer(dropout_rate)
fullyConnectedLayer(24) % Output layer with 24 units for 24-hour GHI forecasting
regressionLayer % Output layer for regression tasks
];
% Set options for training
options = trainingOptions(optimizer, …
‘MaxEpochs’, num_epochs, …
‘MiniBatchSize’, 64, …
‘InitialLearnRate’, learning_rate, …
‘LearnRateSchedule’, ‘piecewise’, …
‘LearnRateDropPeriod’, 50, …
‘LearnRateDropFactor’, 0.1, …
‘ValidationData’, {X_val_reshaped, y_val_reshaped}, …
‘ValidationFrequency’, 10, …
‘ValidationPatience’, 20, …
‘Verbose’, 0, …
‘Plots’, ‘training-progress’);
% Train the LSTM model
lstm_model = trainNetwork(X_train_reshaped, y_train_reshaped, layers, options);
% Predict GHI using the trained model on validation data
y_pred_val = predict(lstm_model, X_val_reshaped);
% Denormalize predictions
y_pred_denormalized = y_pred_val * (max(features.GHI) – min(features.GHI)) + min(features.GHI);
% Calculate evaluation metrics
rmse_val = calculate_rmse(y_val, y_pred_val_denormalized);
mae_val = calculate_mae(y_val, y_pred_val_denormalized);
end
Error using trainNetwork (line 184)
Invalid training data. Predictors must be a N-by-1 cell array of sequences, where N is the number of sequences. All
sequences must have the same feature dimension and at least one time step. hyperparameters fine-tune MATLAB Answers — New Questions
“For loop” to plot graphs of functions
I’m trying to write a matlab (for loop) code to produce the graphs:
Q as a function of A,
F as a function of A,
Z as a function of A
from the known functions f1, f2 and f3
Z = f1 (A, F, Q)
F = f2 (A, Q, Z)
A = f3 (Z, Q).
I made several attempts that were unsuccessful, if anyone can help me I would thank you a lot.I’m trying to write a matlab (for loop) code to produce the graphs:
Q as a function of A,
F as a function of A,
Z as a function of A
from the known functions f1, f2 and f3
Z = f1 (A, F, Q)
F = f2 (A, Q, Z)
A = f3 (Z, Q).
I made several attempts that were unsuccessful, if anyone can help me I would thank you a lot. I’m trying to write a matlab (for loop) code to produce the graphs:
Q as a function of A,
F as a function of A,
Z as a function of A
from the known functions f1, f2 and f3
Z = f1 (A, F, Q)
F = f2 (A, Q, Z)
A = f3 (Z, Q).
I made several attempts that were unsuccessful, if anyone can help me I would thank you a lot. for loop MATLAB Answers — New Questions