Tag Archives: matlab
Global declaration not resolved to a Data Store Memory block registered via the Ports and Data Manager.
i was trying to make a predictive code algorithm however i recieve the same error every time .
code below.
function [Sa,Sb,Sc] = control(T_ref,sflux_ref,wm,i_meas)
% Variables defined in the parameters file
global Ts Rs Lr Lm Ls p tr kr r_sigma t_sigma lambda v states
persistent x_opt Fs %Fsp1 Tp1 g
if isempty(x_opt), x_opt = 1; end
if isempty(Fs), Fs = 0 + 0i*1; end
T_ref = T_ref(1) + 1j*T_ref(2);
sflux_ref = sflux_ref(1) + 1j*sflux(2);
i_meas = i_meas(1) + 1j*i_meas(2);
wm = wm(1) + 1j*wm(2);
% Stator flux estimate
Fs = Fs + Ts*(v(x_opt) – Rs*i_meas);
% Rotor flux estimate
Fr = Lr/Lm*Fs+i_meas*(Lm-Lr*Ls/Lm);
g_opt = 1e10;
for i = 1:8
% i-th voltage vector for current prediction
v_o1 = v(i);
% Stator flux prediction at instant k+1
Fsp1 = Fs + Ts*v_o1 – Rs*Ts*i_meas;
% Stator current prediction at instant k+1
Isp1 = (1+Ts/t_sigma)*i_meas+Ts/(t_sigma+Ts)*(1/r_sigma*((kr/tr-kr*1i*wm)*Fr+v_o1));
% Torque prediction at instant k+1
Tp1 = 3/2*p*imag(conj(Fsp1)*Isp1);
% Cost function
g = abs(T_ref – Tp1)+ lambda*abs(sflux_ref-abs(Fsp1));
if (g<g_opt)
g_opt = g;
x_opt = i;
end
endi was trying to make a predictive code algorithm however i recieve the same error every time .
code below.
function [Sa,Sb,Sc] = control(T_ref,sflux_ref,wm,i_meas)
% Variables defined in the parameters file
global Ts Rs Lr Lm Ls p tr kr r_sigma t_sigma lambda v states
persistent x_opt Fs %Fsp1 Tp1 g
if isempty(x_opt), x_opt = 1; end
if isempty(Fs), Fs = 0 + 0i*1; end
T_ref = T_ref(1) + 1j*T_ref(2);
sflux_ref = sflux_ref(1) + 1j*sflux(2);
i_meas = i_meas(1) + 1j*i_meas(2);
wm = wm(1) + 1j*wm(2);
% Stator flux estimate
Fs = Fs + Ts*(v(x_opt) – Rs*i_meas);
% Rotor flux estimate
Fr = Lr/Lm*Fs+i_meas*(Lm-Lr*Ls/Lm);
g_opt = 1e10;
for i = 1:8
% i-th voltage vector for current prediction
v_o1 = v(i);
% Stator flux prediction at instant k+1
Fsp1 = Fs + Ts*v_o1 – Rs*Ts*i_meas;
% Stator current prediction at instant k+1
Isp1 = (1+Ts/t_sigma)*i_meas+Ts/(t_sigma+Ts)*(1/r_sigma*((kr/tr-kr*1i*wm)*Fr+v_o1));
% Torque prediction at instant k+1
Tp1 = 3/2*p*imag(conj(Fsp1)*Isp1);
% Cost function
g = abs(T_ref – Tp1)+ lambda*abs(sflux_ref-abs(Fsp1));
if (g<g_opt)
g_opt = g;
x_opt = i;
end
end i was trying to make a predictive code algorithm however i recieve the same error every time .
code below.
function [Sa,Sb,Sc] = control(T_ref,sflux_ref,wm,i_meas)
% Variables defined in the parameters file
global Ts Rs Lr Lm Ls p tr kr r_sigma t_sigma lambda v states
persistent x_opt Fs %Fsp1 Tp1 g
if isempty(x_opt), x_opt = 1; end
if isempty(Fs), Fs = 0 + 0i*1; end
T_ref = T_ref(1) + 1j*T_ref(2);
sflux_ref = sflux_ref(1) + 1j*sflux(2);
i_meas = i_meas(1) + 1j*i_meas(2);
wm = wm(1) + 1j*wm(2);
% Stator flux estimate
Fs = Fs + Ts*(v(x_opt) – Rs*i_meas);
% Rotor flux estimate
Fr = Lr/Lm*Fs+i_meas*(Lm-Lr*Ls/Lm);
g_opt = 1e10;
for i = 1:8
% i-th voltage vector for current prediction
v_o1 = v(i);
% Stator flux prediction at instant k+1
Fsp1 = Fs + Ts*v_o1 – Rs*Ts*i_meas;
% Stator current prediction at instant k+1
Isp1 = (1+Ts/t_sigma)*i_meas+Ts/(t_sigma+Ts)*(1/r_sigma*((kr/tr-kr*1i*wm)*Fr+v_o1));
% Torque prediction at instant k+1
Tp1 = 3/2*p*imag(conj(Fsp1)*Isp1);
% Cost function
g = abs(T_ref – Tp1)+ lambda*abs(sflux_ref-abs(Fsp1));
if (g<g_opt)
g_opt = g;
x_opt = i;
end
end ports, data manager, store memory MATLAB Answers — New Questions
CVE-2024-7264 mitigation document Matlab R2021b and below
Is there any document from Mathworks adressing CVE-2024-7264 mitigations or just plain "does not affect Mathworks Matlab products"Is there any document from Mathworks adressing CVE-2024-7264 mitigations or just plain "does not affect Mathworks Matlab products" Is there any document from Mathworks adressing CVE-2024-7264 mitigations or just plain "does not affect Mathworks Matlab products" cve, acas MATLAB Answers — New Questions
PMSM Motor is not responding using TI F28379d LaunchPad with a BOOSTXL-3PhGaNInv booster pack
Motor not responding after dumping and run the code in TI F28379d LaunchPad using BOOSTXL-3PhGaNInv booster pack also chacked the PMW pin no 37-40 but did not get any signal. Is there any way to observe the PWM signal from Lunchpad without using the motor to validate the code generation is working.Motor not responding after dumping and run the code in TI F28379d LaunchPad using BOOSTXL-3PhGaNInv booster pack also chacked the PMW pin no 37-40 but did not get any signal. Is there any way to observe the PWM signal from Lunchpad without using the motor to validate the code generation is working. Motor not responding after dumping and run the code in TI F28379d LaunchPad using BOOSTXL-3PhGaNInv booster pack also chacked the PMW pin no 37-40 but did not get any signal. Is there any way to observe the PWM signal from Lunchpad without using the motor to validate the code generation is working. pmsm, motor control, ti f28379d launchpad, boostxl-3phganinv MATLAB Answers — New Questions
GPSDev Function Unrecognized- ESP32 and GT-U7
When I run the first two code segments I get NaN/NaT or just no output but no error and when I the last two I get the error "Unrecognized function or variable ‘gpsdev’. I have tested the set up using the arduinoIDE and I get proper GPS output through that. I have also checked the baud rate, the communication between the esp32 and computer and that there is proper physical connection. Do you know why I am getting this error/no output? What is the best method to trouble shoot these errors? Any tips would be greatly appreciated. Thank you.
1.
a = arduino(‘COM3′,’ESP32-WROOM-DevKitC’,’Libraries’,’Serial’)
gps = gpsdev(a)
gpsData = gps.read;
latitude = gpsData.LLA(1);
longitude = gpsData.LLA(2);
gpsTime = gpsData.GPSReceiverTime;
% GPS returns UTC datetime. Convert it into system time zone.
gpsTime.TimeZone = ‘local’;
if(~isnan(latitude) && ~isnan(longitude))
% plot the position in geographic coordinates
fig = geoplot(latitude,longitude,’Marker’,"o",’MarkerSize’,6,’Color’,’red’,’MarkerFaceColor’,’red’);
% Sets the latitude and longitude limits of the base Map
geolimits([latitude-0.05,latitude+0.05],[longitude-0.05,longitude+0.05]) ;
% Selects the basemap
geobasemap streets;
timeString = strcat("Timestamp: ",string(gpsTime));
2.
a = arduino(‘COM3′,’ESP32-WROOM-DevKitC’,’Libraries’,’Serial’)
gps = gpsdev(a)
[tt,overruns] = read(gps)
3.
gps = gpsdev(‘COM4′,’OutputFormat’,"timetable")
[tt,overruns] = read(gps)
release(gps)
gps.SamplesPerRead = 2;
read(gps)
4.
s = serialport(‘COM3’, 9600)
gps = gpsdev(s,’OutputFormat’,"matrix")
[lla,speed,course,dops,gpsReceiverTime,timestamp,overruns] = read(gps)
%delete(gps);
%clear gps;
%clear a;
*These codes are adapted from MATWORKS references either by staff or other usersWhen I run the first two code segments I get NaN/NaT or just no output but no error and when I the last two I get the error "Unrecognized function or variable ‘gpsdev’. I have tested the set up using the arduinoIDE and I get proper GPS output through that. I have also checked the baud rate, the communication between the esp32 and computer and that there is proper physical connection. Do you know why I am getting this error/no output? What is the best method to trouble shoot these errors? Any tips would be greatly appreciated. Thank you.
1.
a = arduino(‘COM3′,’ESP32-WROOM-DevKitC’,’Libraries’,’Serial’)
gps = gpsdev(a)
gpsData = gps.read;
latitude = gpsData.LLA(1);
longitude = gpsData.LLA(2);
gpsTime = gpsData.GPSReceiverTime;
% GPS returns UTC datetime. Convert it into system time zone.
gpsTime.TimeZone = ‘local’;
if(~isnan(latitude) && ~isnan(longitude))
% plot the position in geographic coordinates
fig = geoplot(latitude,longitude,’Marker’,"o",’MarkerSize’,6,’Color’,’red’,’MarkerFaceColor’,’red’);
% Sets the latitude and longitude limits of the base Map
geolimits([latitude-0.05,latitude+0.05],[longitude-0.05,longitude+0.05]) ;
% Selects the basemap
geobasemap streets;
timeString = strcat("Timestamp: ",string(gpsTime));
2.
a = arduino(‘COM3′,’ESP32-WROOM-DevKitC’,’Libraries’,’Serial’)
gps = gpsdev(a)
[tt,overruns] = read(gps)
3.
gps = gpsdev(‘COM4′,’OutputFormat’,"timetable")
[tt,overruns] = read(gps)
release(gps)
gps.SamplesPerRead = 2;
read(gps)
4.
s = serialport(‘COM3’, 9600)
gps = gpsdev(s,’OutputFormat’,"matrix")
[lla,speed,course,dops,gpsReceiverTime,timestamp,overruns] = read(gps)
%delete(gps);
%clear gps;
%clear a;
*These codes are adapted from MATWORKS references either by staff or other users When I run the first two code segments I get NaN/NaT or just no output but no error and when I the last two I get the error "Unrecognized function or variable ‘gpsdev’. I have tested the set up using the arduinoIDE and I get proper GPS output through that. I have also checked the baud rate, the communication between the esp32 and computer and that there is proper physical connection. Do you know why I am getting this error/no output? What is the best method to trouble shoot these errors? Any tips would be greatly appreciated. Thank you.
1.
a = arduino(‘COM3′,’ESP32-WROOM-DevKitC’,’Libraries’,’Serial’)
gps = gpsdev(a)
gpsData = gps.read;
latitude = gpsData.LLA(1);
longitude = gpsData.LLA(2);
gpsTime = gpsData.GPSReceiverTime;
% GPS returns UTC datetime. Convert it into system time zone.
gpsTime.TimeZone = ‘local’;
if(~isnan(latitude) && ~isnan(longitude))
% plot the position in geographic coordinates
fig = geoplot(latitude,longitude,’Marker’,"o",’MarkerSize’,6,’Color’,’red’,’MarkerFaceColor’,’red’);
% Sets the latitude and longitude limits of the base Map
geolimits([latitude-0.05,latitude+0.05],[longitude-0.05,longitude+0.05]) ;
% Selects the basemap
geobasemap streets;
timeString = strcat("Timestamp: ",string(gpsTime));
2.
a = arduino(‘COM3′,’ESP32-WROOM-DevKitC’,’Libraries’,’Serial’)
gps = gpsdev(a)
[tt,overruns] = read(gps)
3.
gps = gpsdev(‘COM4′,’OutputFormat’,"timetable")
[tt,overruns] = read(gps)
release(gps)
gps.SamplesPerRead = 2;
read(gps)
4.
s = serialport(‘COM3’, 9600)
gps = gpsdev(s,’OutputFormat’,"matrix")
[lla,speed,course,dops,gpsReceiverTime,timestamp,overruns] = read(gps)
%delete(gps);
%clear gps;
%clear a;
*These codes are adapted from MATWORKS references either by staff or other users gps, esp32, gpsdev, gt-u7, serialport, read() MATLAB Answers — New Questions
unable to read GR-401 gps data with gpsdev or gpsReceiver
I have Navisys GR-401 gps receiver which works just fine with SiRF-Live. I know it uses COM3, but I am unable to read data with matlab.
with:
s = serialport(‘COM3’,9600);
gps = gpsdev(s,’OutputFormat’,"timetable");
and
read(gps)
gives error:
Obtaining the required NMEA sentences (RMC, GGA and GSA) is taking longer than expected. Verify the physical connection of the GPS device to the specified serial port and the configuration of the GPS device.
also
gps = gpsReceiver(‘COM3’);
and
read(gps)
gives error
Warning: Unsuccessful read: The input buffer was filled before the Terminator was reached.
‘serial’ unable to read all requested data. For more information on possible reasons, see Serial Read Warnings.
any ideas what is the culprit here?I have Navisys GR-401 gps receiver which works just fine with SiRF-Live. I know it uses COM3, but I am unable to read data with matlab.
with:
s = serialport(‘COM3’,9600);
gps = gpsdev(s,’OutputFormat’,"timetable");
and
read(gps)
gives error:
Obtaining the required NMEA sentences (RMC, GGA and GSA) is taking longer than expected. Verify the physical connection of the GPS device to the specified serial port and the configuration of the GPS device.
also
gps = gpsReceiver(‘COM3’);
and
read(gps)
gives error
Warning: Unsuccessful read: The input buffer was filled before the Terminator was reached.
‘serial’ unable to read all requested data. For more information on possible reasons, see Serial Read Warnings.
any ideas what is the culprit here? I have Navisys GR-401 gps receiver which works just fine with SiRF-Live. I know it uses COM3, but I am unable to read data with matlab.
with:
s = serialport(‘COM3’,9600);
gps = gpsdev(s,’OutputFormat’,"timetable");
and
read(gps)
gives error:
Obtaining the required NMEA sentences (RMC, GGA and GSA) is taking longer than expected. Verify the physical connection of the GPS device to the specified serial port and the configuration of the GPS device.
also
gps = gpsReceiver(‘COM3’);
and
read(gps)
gives error
Warning: Unsuccessful read: The input buffer was filled before the Terminator was reached.
‘serial’ unable to read all requested data. For more information on possible reasons, see Serial Read Warnings.
any ideas what is the culprit here? gps, gr-401 MATLAB Answers — New Questions
delete zeros rows and columns
I try this code to delete all row and column with all zero values in them. It simply works for deleting the columns with all zero values abut it does not work for rows! Can anybody please help me?
data=[0 0 0 0 0 0 0 0; 0 0 2 3 4 0 1 0; 0 0 1 2 3 0 0 0];
data( all( ~any( data), 2 ), : ) = []; % removes all rows with all zero
data( :, all( ~any( data ), 1 ) ) = []; % and columns
I mean the first line (% removes all rows with all zero) does not work!I try this code to delete all row and column with all zero values in them. It simply works for deleting the columns with all zero values abut it does not work for rows! Can anybody please help me?
data=[0 0 0 0 0 0 0 0; 0 0 2 3 4 0 1 0; 0 0 1 2 3 0 0 0];
data( all( ~any( data), 2 ), : ) = []; % removes all rows with all zero
data( :, all( ~any( data ), 1 ) ) = []; % and columns
I mean the first line (% removes all rows with all zero) does not work! I try this code to delete all row and column with all zero values in them. It simply works for deleting the columns with all zero values abut it does not work for rows! Can anybody please help me?
data=[0 0 0 0 0 0 0 0; 0 0 2 3 4 0 1 0; 0 0 1 2 3 0 0 0];
data( all( ~any( data), 2 ), : ) = []; % removes all rows with all zero
data( :, all( ~any( data ), 1 ) ) = []; % and columns
I mean the first line (% removes all rows with all zero) does not work! matrix, array, zeros, delete MATLAB Answers — New Questions
How to find out if a logical array is all zeros?
I have a logical array that is 100×1 logical. sometimes it contains a mix of numbers and sometimes it contains all 0s.
How would i go about making an if statement that checks to see if all 100×1 is 0s and if all 0s = do something
I thought i was correct in using any command but im not sure that works correctly for me..
Thanks!I have a logical array that is 100×1 logical. sometimes it contains a mix of numbers and sometimes it contains all 0s.
How would i go about making an if statement that checks to see if all 100×1 is 0s and if all 0s = do something
I thought i was correct in using any command but im not sure that works correctly for me..
Thanks! I have a logical array that is 100×1 logical. sometimes it contains a mix of numbers and sometimes it contains all 0s.
How would i go about making an if statement that checks to see if all 100×1 is 0s and if all 0s = do something
I thought i was correct in using any command but im not sure that works correctly for me..
Thanks! array, logic, if statement MATLAB Answers — New Questions
I need help in this issue. it’s been long time getting this error.
Unable to perform assignment because the left and right sides have a different number of elements.
Error in EM_RTSS>kalman_filter (line 144)
Z_estimates(n) = Z_est; % Store state estimate
Error in EM_RTSS (line 40)
[Z_estimates, P_estimates] = kalman_filter(A, B, S, sigma, mu1, S1, temp);Unable to perform assignment because the left and right sides have a different number of elements.
Error in EM_RTSS>kalman_filter (line 144)
Z_estimates(n) = Z_est; % Store state estimate
Error in EM_RTSS (line 40)
[Z_estimates, P_estimates] = kalman_filter(A, B, S, sigma, mu1, S1, temp); Unable to perform assignment because the left and right sides have a different number of elements.
Error in EM_RTSS>kalman_filter (line 144)
Z_estimates(n) = Z_est; % Store state estimate
Error in EM_RTSS (line 40)
[Z_estimates, P_estimates] = kalman_filter(A, B, S, sigma, mu1, S1, temp); kalman filter MATLAB Answers — New Questions
How to place random CNT’s in a box domain with random curves and orientation ?
Hi all, what i want is a code that can actually place random carbon nanotubes in a cube domain so that i can use it in comsol livelink MATLAB bellow is a code that puts spheres which i found in this forum i need it based on that.. :
function P = GetRandomSpheres(nWant, Width, Radius)
% INPUT:
% nWant: Number of spheres
% Width: Dimension of 3d box as [1 x 3] double vector
% Radius: Radius of spheres
% OUTPUT:
% P: [nWant x 3] matrix, centers
P = zeros(nWant, 3);
R2 = (2 * Radius) ^ 2; % Squared once instead of SQRT each time
W = Width – 2 * Radius; % Avoid interesction with borders
iLoop = 1; % Security break to avoid infinite loop
nValid = 0;
while nValid < nWant && iLoop < 1e12
newP = rand(1, 3) .* W + Radius;
% Auto-expanding, need Matlab >= R2016b. For earlier versions:
% Dist2 = sum(bsxfun(@minus, P(1:nValid, :), newP) .^ 2, 2);
Dist2 = sum((P(1:nValid, 🙂 – newP) .^ 2, 2);
if all(Dist2 > R2)
% Success: The new point does not touch existing sheres:
nValid = nValid + 1; % Append this point
P(nValid, 🙂 = newP;
end
iLoop = iLoop + 1;
end
% Stop if too few values have been found:
if nValid < nWant
error(‘Cannot find wanted number of points in %d iterations.’, iLoop)
end
end
n = 100;
R = 5;
P = GetRandomSpheres(n, [100, 100, 100], R);
figure
axes(‘NextPlot’, ‘add’, …
‘XLim’, [0, 100], ‘YLim’, [0, 100], ‘ZLim’, [0, 100]);
view(3);
[X, Y, Z] = sphere();
for k = 1:n
surf(X * R + P(k, 1), Y * R + P(k, 2), Z * R + P(k, 3));
endHi all, what i want is a code that can actually place random carbon nanotubes in a cube domain so that i can use it in comsol livelink MATLAB bellow is a code that puts spheres which i found in this forum i need it based on that.. :
function P = GetRandomSpheres(nWant, Width, Radius)
% INPUT:
% nWant: Number of spheres
% Width: Dimension of 3d box as [1 x 3] double vector
% Radius: Radius of spheres
% OUTPUT:
% P: [nWant x 3] matrix, centers
P = zeros(nWant, 3);
R2 = (2 * Radius) ^ 2; % Squared once instead of SQRT each time
W = Width – 2 * Radius; % Avoid interesction with borders
iLoop = 1; % Security break to avoid infinite loop
nValid = 0;
while nValid < nWant && iLoop < 1e12
newP = rand(1, 3) .* W + Radius;
% Auto-expanding, need Matlab >= R2016b. For earlier versions:
% Dist2 = sum(bsxfun(@minus, P(1:nValid, :), newP) .^ 2, 2);
Dist2 = sum((P(1:nValid, 🙂 – newP) .^ 2, 2);
if all(Dist2 > R2)
% Success: The new point does not touch existing sheres:
nValid = nValid + 1; % Append this point
P(nValid, 🙂 = newP;
end
iLoop = iLoop + 1;
end
% Stop if too few values have been found:
if nValid < nWant
error(‘Cannot find wanted number of points in %d iterations.’, iLoop)
end
end
n = 100;
R = 5;
P = GetRandomSpheres(n, [100, 100, 100], R);
figure
axes(‘NextPlot’, ‘add’, …
‘XLim’, [0, 100], ‘YLim’, [0, 100], ‘ZLim’, [0, 100]);
view(3);
[X, Y, Z] = sphere();
for k = 1:n
surf(X * R + P(k, 1), Y * R + P(k, 2), Z * R + P(k, 3));
end Hi all, what i want is a code that can actually place random carbon nanotubes in a cube domain so that i can use it in comsol livelink MATLAB bellow is a code that puts spheres which i found in this forum i need it based on that.. :
function P = GetRandomSpheres(nWant, Width, Radius)
% INPUT:
% nWant: Number of spheres
% Width: Dimension of 3d box as [1 x 3] double vector
% Radius: Radius of spheres
% OUTPUT:
% P: [nWant x 3] matrix, centers
P = zeros(nWant, 3);
R2 = (2 * Radius) ^ 2; % Squared once instead of SQRT each time
W = Width – 2 * Radius; % Avoid interesction with borders
iLoop = 1; % Security break to avoid infinite loop
nValid = 0;
while nValid < nWant && iLoop < 1e12
newP = rand(1, 3) .* W + Radius;
% Auto-expanding, need Matlab >= R2016b. For earlier versions:
% Dist2 = sum(bsxfun(@minus, P(1:nValid, :), newP) .^ 2, 2);
Dist2 = sum((P(1:nValid, 🙂 – newP) .^ 2, 2);
if all(Dist2 > R2)
% Success: The new point does not touch existing sheres:
nValid = nValid + 1; % Append this point
P(nValid, 🙂 = newP;
end
iLoop = iLoop + 1;
end
% Stop if too few values have been found:
if nValid < nWant
error(‘Cannot find wanted number of points in %d iterations.’, iLoop)
end
end
n = 100;
R = 5;
P = GetRandomSpheres(n, [100, 100, 100], R);
figure
axes(‘NextPlot’, ‘add’, …
‘XLim’, [0, 100], ‘YLim’, [0, 100], ‘ZLim’, [0, 100]);
view(3);
[X, Y, Z] = sphere();
for k = 1:n
surf(X * R + P(k, 1), Y * R + P(k, 2), Z * R + P(k, 3));
end matlab, random, java, comsol, geometry, matlab code, programming MATLAB Answers — New Questions
Dynamic dashboard radio button options
Hello!
I was curious if it was possible to make the options of a radio button change based on another radio button.
This is a manually created example that shows visually what I want, but doesn’t actually work. If you pick a different category, the selection options automatically change:Hello!
I was curious if it was possible to make the options of a radio button change based on another radio button.
This is a manually created example that shows visually what I want, but doesn’t actually work. If you pick a different category, the selection options automatically change: Hello!
I was curious if it was possible to make the options of a radio button change based on another radio button.
This is a manually created example that shows visually what I want, but doesn’t actually work. If you pick a different category, the selection options automatically change: dashboard, radio button MATLAB Answers — New Questions
Displaying a struct containing gpuArray fields takes an extremely long time
I find that when I create a struct (or object) whose fields are large gpuArrays, it takes an extremely long time (1-2 minutes) to display the struct at the command line. Example:
>> c.data=gpuArray.rand(266,354,894,’single’);
>> tic; c, toc
c =
struct with fields:
data: [266×354×894 gpuArray]
Elapsed time is 100.266106 seconds.
I have observed this in R2024b on two platforms,
(1) Windows 10; NVIDIA GeForce RTX 4080 SUPER
(2) Windows 11; NVIDIA RTX 5000 Ada Generation
Does anyone know why this might be happening?I find that when I create a struct (or object) whose fields are large gpuArrays, it takes an extremely long time (1-2 minutes) to display the struct at the command line. Example:
>> c.data=gpuArray.rand(266,354,894,’single’);
>> tic; c, toc
c =
struct with fields:
data: [266×354×894 gpuArray]
Elapsed time is 100.266106 seconds.
I have observed this in R2024b on two platforms,
(1) Windows 10; NVIDIA GeForce RTX 4080 SUPER
(2) Windows 11; NVIDIA RTX 5000 Ada Generation
Does anyone know why this might be happening? I find that when I create a struct (or object) whose fields are large gpuArrays, it takes an extremely long time (1-2 minutes) to display the struct at the command line. Example:
>> c.data=gpuArray.rand(266,354,894,’single’);
>> tic; c, toc
c =
struct with fields:
data: [266×354×894 gpuArray]
Elapsed time is 100.266106 seconds.
I have observed this in R2024b on two platforms,
(1) Windows 10; NVIDIA GeForce RTX 4080 SUPER
(2) Windows 11; NVIDIA RTX 5000 Ada Generation
Does anyone know why this might be happening? struct, gpuarray, display MATLAB Answers — New Questions
extract numbers from an image
Howdy,
I would like to extract the numbers inside the squares, how do you recommend I do it.Howdy,
I would like to extract the numbers inside the squares, how do you recommend I do it. Howdy,
I would like to extract the numbers inside the squares, how do you recommend I do it. image-processing, image analysis MATLAB Answers — New Questions
Distinguish incomplete and complete triangles from a given image and display their respective numbers
I have a smoothed edge image and would like to highlight with 2 different colors (green – complete triangle, red – incomplete traingle) and display their respective count (how many incomplete triangles and how many complete triangles). I have attached image for reference.I have a smoothed edge image and would like to highlight with 2 different colors (green – complete triangle, red – incomplete traingle) and display their respective count (how many incomplete triangles and how many complete triangles). I have attached image for reference. I have a smoothed edge image and would like to highlight with 2 different colors (green – complete triangle, red – incomplete traingle) and display their respective count (how many incomplete triangles and how many complete triangles). I have attached image for reference. image processing, detection, triangle, image segmentation MATLAB Answers — New Questions
how to show images at a point in a plot?
I have an autonomous vehicle with a camera that follows a predetermined path. Ive already found a way to save each frame of the video and figure out which lat and long each frame belongs to, what im having trouble with is plotting the images in a for loop. I feel like im close, below is my code:
P = uigetdir(‘C:’);
S1 = dir(fullfile(P,’*.png’));
n_frame = numel(S1);
LatSize = size(Lat1, 1);
LongSize = size(Long1, 1);
FrameCount = LatSize/n_frame;
Lat = Lat1(1:FrameCount:end);
Long = Long1(1:FrameCount:end);
for i = 1:n_frame
F2 = fullfile(S1(i).name);
I{i} = imread(F2(i));
plot(Long, Lat)
axes(‘Position’, [Long(i,:) Lat(i,:) .5 .3])
imshow(I)
end
What am I missing here? I get this error when I run the code:
Unable to find file "F"
The various frames of the video are labeled Frame 0001.png, Frame 0002.png and so, there are 739 frames of the video and I want to plot each frame at the point they were recorded. My ultimate goal is to make it so you can click the plot and the picture will appear but ill deal with that part later. Any help is appreciated, thanks!I have an autonomous vehicle with a camera that follows a predetermined path. Ive already found a way to save each frame of the video and figure out which lat and long each frame belongs to, what im having trouble with is plotting the images in a for loop. I feel like im close, below is my code:
P = uigetdir(‘C:’);
S1 = dir(fullfile(P,’*.png’));
n_frame = numel(S1);
LatSize = size(Lat1, 1);
LongSize = size(Long1, 1);
FrameCount = LatSize/n_frame;
Lat = Lat1(1:FrameCount:end);
Long = Long1(1:FrameCount:end);
for i = 1:n_frame
F2 = fullfile(S1(i).name);
I{i} = imread(F2(i));
plot(Long, Lat)
axes(‘Position’, [Long(i,:) Lat(i,:) .5 .3])
imshow(I)
end
What am I missing here? I get this error when I run the code:
Unable to find file "F"
The various frames of the video are labeled Frame 0001.png, Frame 0002.png and so, there are 739 frames of the video and I want to plot each frame at the point they were recorded. My ultimate goal is to make it so you can click the plot and the picture will appear but ill deal with that part later. Any help is appreciated, thanks! I have an autonomous vehicle with a camera that follows a predetermined path. Ive already found a way to save each frame of the video and figure out which lat and long each frame belongs to, what im having trouble with is plotting the images in a for loop. I feel like im close, below is my code:
P = uigetdir(‘C:’);
S1 = dir(fullfile(P,’*.png’));
n_frame = numel(S1);
LatSize = size(Lat1, 1);
LongSize = size(Long1, 1);
FrameCount = LatSize/n_frame;
Lat = Lat1(1:FrameCount:end);
Long = Long1(1:FrameCount:end);
for i = 1:n_frame
F2 = fullfile(S1(i).name);
I{i} = imread(F2(i));
plot(Long, Lat)
axes(‘Position’, [Long(i,:) Lat(i,:) .5 .3])
imshow(I)
end
What am I missing here? I get this error when I run the code:
Unable to find file "F"
The various frames of the video are labeled Frame 0001.png, Frame 0002.png and so, there are 739 frames of the video and I want to plot each frame at the point they were recorded. My ultimate goal is to make it so you can click the plot and the picture will appear but ill deal with that part later. Any help is appreciated, thanks! imread MATLAB Answers — New Questions
MPU6050 display raw data and fft from the reading get
from this code what is the problem that i faced because the fft not show
a = arduino;
imu = mpu6050(a);
xlabel(‘Count’);
ylabel(‘Acceleration (m/s^2)’);
title(‘Acceleration values from mpu6050 sensor (Z-axis only)’);
z_val = animatedline(‘Color’,’b’);
axis tight;
legend(‘Acceleration in Z-axis’);
stop_time = 100;
count = 1;
tic;
while(toc <= stop_time)
[accel] = readAcceleration(imu);
if ~isempty(accel)
addpoints(z_val,count,accel(:,3));
% Compute FFT of the Z-axis acceleration
fft_z = fft(accel(:,3));
n = length(fft_z);
freq = (0:n-1)*(100/stop_time)/n; % Assuming sampling rate based on stop_time
% Plot the FFT magnitude
subplot(2,1,2);
plot(freq, abs(fft_z));
xlabel(‘Frequency (Hz)’);
ylabel(‘Magnitude’);
title(‘FFT of Z-axis Acceleration’);
drawnow limitrate;
count = count + 1;
end
endfrom this code what is the problem that i faced because the fft not show
a = arduino;
imu = mpu6050(a);
xlabel(‘Count’);
ylabel(‘Acceleration (m/s^2)’);
title(‘Acceleration values from mpu6050 sensor (Z-axis only)’);
z_val = animatedline(‘Color’,’b’);
axis tight;
legend(‘Acceleration in Z-axis’);
stop_time = 100;
count = 1;
tic;
while(toc <= stop_time)
[accel] = readAcceleration(imu);
if ~isempty(accel)
addpoints(z_val,count,accel(:,3));
% Compute FFT of the Z-axis acceleration
fft_z = fft(accel(:,3));
n = length(fft_z);
freq = (0:n-1)*(100/stop_time)/n; % Assuming sampling rate based on stop_time
% Plot the FFT magnitude
subplot(2,1,2);
plot(freq, abs(fft_z));
xlabel(‘Frequency (Hz)’);
ylabel(‘Magnitude’);
title(‘FFT of Z-axis Acceleration’);
drawnow limitrate;
count = count + 1;
end
end from this code what is the problem that i faced because the fft not show
a = arduino;
imu = mpu6050(a);
xlabel(‘Count’);
ylabel(‘Acceleration (m/s^2)’);
title(‘Acceleration values from mpu6050 sensor (Z-axis only)’);
z_val = animatedline(‘Color’,’b’);
axis tight;
legend(‘Acceleration in Z-axis’);
stop_time = 100;
count = 1;
tic;
while(toc <= stop_time)
[accel] = readAcceleration(imu);
if ~isempty(accel)
addpoints(z_val,count,accel(:,3));
% Compute FFT of the Z-axis acceleration
fft_z = fft(accel(:,3));
n = length(fft_z);
freq = (0:n-1)*(100/stop_time)/n; % Assuming sampling rate based on stop_time
% Plot the FFT magnitude
subplot(2,1,2);
plot(freq, abs(fft_z));
xlabel(‘Frequency (Hz)’);
ylabel(‘Magnitude’);
title(‘FFT of Z-axis Acceleration’);
drawnow limitrate;
count = count + 1;
end
end signal processing, mpu6050 MATLAB Answers — New Questions
How the Delay one step block and stop time ( simulation time) infuence each other on simulink?
I want to have a fixed delay on the incoming resources going in the resource pool. For that matter I am using a delay one step block as seen in the attached file. The problem is that, I want to run the simulation let us say for 1000 mins or 10000 mins and the delay in each case be constant but I cannot achieve that. It seems to me there is a connection between the stop time and the delay length in the one step delay block. In the attached file without changing the values inside the blocks and simply by changing the stop time it can be clearly seen in the resource pool scope that this time changes. Any help would be appreciated!I want to have a fixed delay on the incoming resources going in the resource pool. For that matter I am using a delay one step block as seen in the attached file. The problem is that, I want to run the simulation let us say for 1000 mins or 10000 mins and the delay in each case be constant but I cannot achieve that. It seems to me there is a connection between the stop time and the delay length in the one step delay block. In the attached file without changing the values inside the blocks and simply by changing the stop time it can be clearly seen in the resource pool scope that this time changes. Any help would be appreciated! I want to have a fixed delay on the incoming resources going in the resource pool. For that matter I am using a delay one step block as seen in the attached file. The problem is that, I want to run the simulation let us say for 1000 mins or 10000 mins and the delay in each case be constant but I cannot achieve that. It seems to me there is a connection between the stop time and the delay length in the one step delay block. In the attached file without changing the values inside the blocks and simply by changing the stop time it can be clearly seen in the resource pool scope that this time changes. Any help would be appreciated! #simulink, delayonestepblock MATLAB Answers — New Questions
writetable/readtable with multi-line headers
How can I use writetable to make a table to excel sheet and .csv file which has multi-line headers. Headers can include both per-variable headers like units and description, but also per-table headers like description or comments.
For example, take a table like below.
T = table(["Blue";"Red";"Green"],[50;100;75],[0.1;0.5;0.9],…
VariableNames={‘Color’,’Weight’,’Temp’});
T.Properties.VariableUnits = ["[-]";"[kg]";"°C"];
T.Properties.VariableDescriptions = ["Outside Color";"Gross Weight";"Melting Point"];
T.Properties.Description = "Playdough Properties Chart";
Now I want to make it look like this in excel and .csv files
I know to do this by other means, but I would like to be able to do it with writetable, and also to read it back in with readtable.
Is there a straight-forward way of doing this?How can I use writetable to make a table to excel sheet and .csv file which has multi-line headers. Headers can include both per-variable headers like units and description, but also per-table headers like description or comments.
For example, take a table like below.
T = table(["Blue";"Red";"Green"],[50;100;75],[0.1;0.5;0.9],…
VariableNames={‘Color’,’Weight’,’Temp’});
T.Properties.VariableUnits = ["[-]";"[kg]";"°C"];
T.Properties.VariableDescriptions = ["Outside Color";"Gross Weight";"Melting Point"];
T.Properties.Description = "Playdough Properties Chart";
Now I want to make it look like this in excel and .csv files
I know to do this by other means, but I would like to be able to do it with writetable, and also to read it back in with readtable.
Is there a straight-forward way of doing this? How can I use writetable to make a table to excel sheet and .csv file which has multi-line headers. Headers can include both per-variable headers like units and description, but also per-table headers like description or comments.
For example, take a table like below.
T = table(["Blue";"Red";"Green"],[50;100;75],[0.1;0.5;0.9],…
VariableNames={‘Color’,’Weight’,’Temp’});
T.Properties.VariableUnits = ["[-]";"[kg]";"°C"];
T.Properties.VariableDescriptions = ["Outside Color";"Gross Weight";"Melting Point"];
T.Properties.Description = "Playdough Properties Chart";
Now I want to make it look like this in excel and .csv files
I know to do this by other means, but I would like to be able to do it with writetable, and also to read it back in with readtable.
Is there a straight-forward way of doing this? tables, csv, excel MATLAB Answers — New Questions
How do I include a command line in my app when using MATLAB Compiler?
I created an app using the MATLAB App Designer and want to use MATLAB Compiler so others are able to use my app without having MATLAB. The problem I’m running into is that the app asks the user questions in the command window, and I don’t know of a good method to add this command window when compiling.
I know there’s an option when packaging the app to include the Windows Command Shell when the app is opened, but that shel doesn’t allow you to move directories, so it makes adding files to my app more difficult than it needs to be.
Is there a way to include a "customized" command shell in the app that either allows the user to change directories, or is just located in the directory the app is saved in?I created an app using the MATLAB App Designer and want to use MATLAB Compiler so others are able to use my app without having MATLAB. The problem I’m running into is that the app asks the user questions in the command window, and I don’t know of a good method to add this command window when compiling.
I know there’s an option when packaging the app to include the Windows Command Shell when the app is opened, but that shel doesn’t allow you to move directories, so it makes adding files to my app more difficult than it needs to be.
Is there a way to include a "customized" command shell in the app that either allows the user to change directories, or is just located in the directory the app is saved in? I created an app using the MATLAB App Designer and want to use MATLAB Compiler so others are able to use my app without having MATLAB. The problem I’m running into is that the app asks the user questions in the command window, and I don’t know of a good method to add this command window when compiling.
I know there’s an option when packaging the app to include the Windows Command Shell when the app is opened, but that shel doesn’t allow you to move directories, so it makes adding files to my app more difficult than it needs to be.
Is there a way to include a "customized" command shell in the app that either allows the user to change directories, or is just located in the directory the app is saved in? matlab compiler, app designer MATLAB Answers — New Questions
Simulink model output heavily dependent on relative tolerance
I have a relatively large Simulink model that I am validating using a data set. This model is using the ECEF 6DOF block with only a gravitational force as the input.
I have observed that the Simulink model output varies considerably depending on the relative tolerance selected (ranging from 1e-5 to 1e-12), with the output approaching the data set values as the relative tolerance passes below 1e-10. Decreasing the relative tolerance has a significant negative impact on model runtime, so I would like to keep the relative tolerance at a reasonable value while maintaining accuracy in the model results.
Is a significant variation with changing relative tolerance (below the obvious candidates such as >= 1e-5) expected for a typical Simulink model?I have a relatively large Simulink model that I am validating using a data set. This model is using the ECEF 6DOF block with only a gravitational force as the input.
I have observed that the Simulink model output varies considerably depending on the relative tolerance selected (ranging from 1e-5 to 1e-12), with the output approaching the data set values as the relative tolerance passes below 1e-10. Decreasing the relative tolerance has a significant negative impact on model runtime, so I would like to keep the relative tolerance at a reasonable value while maintaining accuracy in the model results.
Is a significant variation with changing relative tolerance (below the obvious candidates such as >= 1e-5) expected for a typical Simulink model? I have a relatively large Simulink model that I am validating using a data set. This model is using the ECEF 6DOF block with only a gravitational force as the input.
I have observed that the Simulink model output varies considerably depending on the relative tolerance selected (ranging from 1e-5 to 1e-12), with the output approaching the data set values as the relative tolerance passes below 1e-10. Decreasing the relative tolerance has a significant negative impact on model runtime, so I would like to keep the relative tolerance at a reasonable value while maintaining accuracy in the model results.
Is a significant variation with changing relative tolerance (below the obvious candidates such as >= 1e-5) expected for a typical Simulink model? relative tolerance MATLAB Answers — New Questions
Using clc in my simple scipt prevents user input question being displayed
I wrote a simple script to ask for a user’s age
age = input(‘What is your age?….’)
This works as expected.
However, if I insert a clc in front of this in the code, it does not display the question to the user in the command window. I don’t know what is happening here.
Any thoughts?
Thanks
NickI wrote a simple script to ask for a user’s age
age = input(‘What is your age?….’)
This works as expected.
However, if I insert a clc in front of this in the code, it does not display the question to the user in the command window. I don’t know what is happening here.
Any thoughts?
Thanks
Nick I wrote a simple script to ask for a user’s age
age = input(‘What is your age?….’)
This works as expected.
However, if I insert a clc in front of this in the code, it does not display the question to the user in the command window. I don’t know what is happening here.
Any thoughts?
Thanks
Nick clc bug MATLAB Answers — New Questions