Tag Archives: matlab
Errors in feedback control after setting the input of a prismatic joint to motion/provided by input
Hello, I am currently controlling the prismatic joint actuators of a Stewart platform using Simulink. I have set the input to motion/provided by input in order to change the position of the eight actuators over time. However, when I try to perform feedback control in the simulation, I encounter errors as shown in the image below. Feedback control works when the input is set to force, but why do these errors occur when the input is set to motion? If anyone knows the answer, I would be very grateful for your help.Hello, I am currently controlling the prismatic joint actuators of a Stewart platform using Simulink. I have set the input to motion/provided by input in order to change the position of the eight actuators over time. However, when I try to perform feedback control in the simulation, I encounter errors as shown in the image below. Feedback control works when the input is set to force, but why do these errors occur when the input is set to motion? If anyone knows the answer, I would be very grateful for your help. Hello, I am currently controlling the prismatic joint actuators of a Stewart platform using Simulink. I have set the input to motion/provided by input in order to change the position of the eight actuators over time. However, when I try to perform feedback control in the simulation, I encounter errors as shown in the image below. Feedback control works when the input is set to force, but why do these errors occur when the input is set to motion? If anyone knows the answer, I would be very grateful for your help. simulink, simscape MATLAB Answers — New Questions
Colorbar with a range taken from a variable
Hello,
I have a matrix organized in this way:
M= col1, col2…. col10
col1 and col2 are the x and y position of the data, col10 is a property of this data and it is a number.
I would like to use the numbers in col10 to make a colormap and assign ot every point a specific color that depends on the value in col10.
I did this long time ago, but I don’t remember how, can somebody help me, please?
Thanks
F.Hello,
I have a matrix organized in this way:
M= col1, col2…. col10
col1 and col2 are the x and y position of the data, col10 is a property of this data and it is a number.
I would like to use the numbers in col10 to make a colormap and assign ot every point a specific color that depends on the value in col10.
I did this long time ago, but I don’t remember how, can somebody help me, please?
Thanks
F. Hello,
I have a matrix organized in this way:
M= col1, col2…. col10
col1 and col2 are the x and y position of the data, col10 is a property of this data and it is a number.
I would like to use the numbers in col10 to make a colormap and assign ot every point a specific color that depends on the value in col10.
I did this long time ago, but I don’t remember how, can somebody help me, please?
Thanks
F. plot MATLAB Answers — New Questions
Can the data type of a Simulink PS converter be boolean instead of double/single?
I have a signal. A data type conversion block is being used to convert the data type of the signal to boolean. The signal then goes to Simulink PS converter. Upon doing so the follwoing error pops up.
Request for help to use boolean data type signals with Simulink PS converters.I have a signal. A data type conversion block is being used to convert the data type of the signal to boolean. The signal then goes to Simulink PS converter. Upon doing so the follwoing error pops up.
Request for help to use boolean data type signals with Simulink PS converters. I have a signal. A data type conversion block is being used to convert the data type of the signal to boolean. The signal then goes to Simulink PS converter. Upon doing so the follwoing error pops up.
Request for help to use boolean data type signals with Simulink PS converters. matlab, simscape, ps converters, data type MATLAB Answers — New Questions
MinidroneCompetition track evaluation, how can I build our own tracks?
As the rules introduced, our minidrone will be tested on multiple tracks. Does anyone know who we can build our own tracks for evaluation in the simulink?As the rules introduced, our minidrone will be tested on multiple tracks. Does anyone know who we can build our own tracks for evaluation in the simulink? As the rules introduced, our minidrone will be tested on multiple tracks. Does anyone know who we can build our own tracks for evaluation in the simulink? minidronecompetition MATLAB Answers — New Questions
possible solution to speed up with power function?
Is there any solution to speed up this code? The power function is too expensive. Any help is much appreciated.
tic
N = 1000000;
Linput = 500;
t = 1:Linput;
mTT = rand(N,1);
alf = rand(N,1);
beta = mTT./alf;
faktor = 1./(beta.^alf.*gamma(alf));
A = t.^(alf-1);
B = -t./beta ;
C = faktor.*A.*exp(B);
toc
Elapsed time is 104.574729 seconds.Is there any solution to speed up this code? The power function is too expensive. Any help is much appreciated.
tic
N = 1000000;
Linput = 500;
t = 1:Linput;
mTT = rand(N,1);
alf = rand(N,1);
beta = mTT./alf;
faktor = 1./(beta.^alf.*gamma(alf));
A = t.^(alf-1);
B = -t./beta ;
C = faktor.*A.*exp(B);
toc
Elapsed time is 104.574729 seconds. Is there any solution to speed up this code? The power function is too expensive. Any help is much appreciated.
tic
N = 1000000;
Linput = 500;
t = 1:Linput;
mTT = rand(N,1);
alf = rand(N,1);
beta = mTT./alf;
faktor = 1./(beta.^alf.*gamma(alf));
A = t.^(alf-1);
B = -t./beta ;
C = faktor.*A.*exp(B);
toc
Elapsed time is 104.574729 seconds. speed up with power function MATLAB Answers — New Questions
How to find the orientation of the entire platform by looking at the overall geometey of the objects/dots?
Hi, Im trying to find the orientation that is roll and pitch angle of my platform by analysing the overall geometery of the dots. To do so i have firstly detected the dots by using standard deviation and k-means clustering and dividing the image into 5×5 boxes then a plane fitting curve method is used to determine the overall geometery of the dots which further gives orientation of the plate. The obtained angles are incorrect what might have possibly gone wrong please help and suggest any possible solution. I’m actually trying to implement a blass on a plate system and i want to detect the orientation of the plate using webcam. Also im using MATLAB 2021a therefore im not sure how to calibrate my camera for such a pattern. The MATLAB code is given below;
clear all;
clc;
close all;
% Create a webcam object
cap = webcam(‘Adesso CyberTrack H3’);
% Adjust camera settings if supported
try
% Set the exposure time (shutter speed) in seconds
exposureTime = 0.01; % Adjust as needed
cap.ExposureMode = ‘manual’;
cap.Exposure = exposureTime;
catch ME
disp(‘Warning: Unable to set exposure time for the camera.’);
disp(ME.message);
end
% Create the background subtractor object for ball detection
back_sub = vision.ForegroundDetector(‘NumTrainingFrames’, 100, ‘NumGaussians’, 3, ‘MinimumBackgroundRatio’, 0.7);
% Create structuring element for morphological operation
se = strel(‘rectangle’, [20, 20]);
% Initialize calibration values
calibration_pitch = 0;
calibration_roll = 0;
% Calibrate the system to set initial pitch and roll to zero
frame = snapshot(cap);
I_gray = rgb2gray(frame);
I_contrast = imadjust(I_gray);
bw = imbinarize(I_contrast, ‘adaptive’);
bw_filled = imfill(bw, ‘holes’);
bw_cleaned = bwareaopen(bw_filled, 50);
stats = regionprops(‘table’, bw_cleaned, ‘Centroid’, ‘BoundingBox’);
centroids = stats.Centroid;
if size(centroids, 1) >= 3
X = centroids(:, 1);
Y = centroids(:, 2);
Z = linspace(0, 1, size(centroids, 1))’;
A = [X, Y, ones(size(X))];
coeffs = A Z;
normal = [-coeffs(1), -coeffs(2), 1];
normal = normal / norm(normal);
calibration_pitch = asin(normal(1));
calibration_roll = asin(normal(2));
disp([‘Calibration Pitch: ‘, num2str(calibration_pitch), ‘ degrees’]);
disp([‘Calibration Roll: ‘, num2str(calibration_roll), ‘ degrees’]);
else
disp(‘Not enough dots detected for calibration.’);
end
while true
% Read frame from webcam
frame = snapshot(cap);
% Part 1: Dot Detection and Tilt Angle Calculation
I_gray = rgb2gray(frame);
I_contrast = imadjust(I_gray);
bw = imbinarize(I_contrast, ‘adaptive’);
bw_filled = imfill(bw, ‘holes’);
bw_cleaned = bwareaopen(bw_filled, 50);
stats = regionprops(‘table’, bw_cleaned, ‘Centroid’, ‘BoundingBox’);
centroids = stats.Centroid;
boundingBoxes = stats.BoundingBox;
if size(centroids, 1) >= 3
X = centroids(:, 1);
Y = centroids(:, 2);
Z = linspace(0, 1, size(centroids, 1))’;
A = [X, Y, ones(size(X))];
coeffs = A Z;
normal = [-coeffs(1), -coeffs(2), 1];
normal = normal / norm(normal);
pitch = asin(normal(1)) – calibration_pitch;
roll = asin(normal(2)) – calibration_roll;
yaw = 0;
disp([‘Pitch (Tilt around Y-axis): ‘, num2str(pitch), ‘ degrees’]);
disp([‘Roll (Tilt around X-axis): ‘, num2str(roll), ‘ degrees’]);
disp([‘Yaw (Rotation around Z-axis): ‘, num2str(yaw), ‘ degrees’]);
else
pitch = 0;
roll = 0;
yaw = 0;
disp(‘Not enough dots detected to fit a plane.’);
end
for i = 1:size(boundingBoxes, 1)
frame = insertShape(frame, ‘Rectangle’, boundingBoxes(i, :), ‘Color’, ‘g’, ‘LineWidth’, 2);
end
fg_mask = step(back_sub, frame);
fg_mask = imclose(fg_mask, se);
fg_mask = medfilt2(fg_mask, [5, 5]);
fg_mask = uint8(fg_mask) * 255;
[contours, ~] = bwlabel(fg_mask);
stats = regionprops(contours, ‘Area’, ‘BoundingBox’, ‘Centroid’);
if ~isempty(stats)
[~, max_index] = max([stats.Area]);
centroid = stats(max_index).Centroid;
boundingBox = stats(max_index).BoundingBox;
frame = insertShape(frame, ‘Rectangle’, boundingBox, ‘Color’, [0, 255, 0], ‘LineWidth’, 3);
text = [‘x: ‘, num2str(centroid(1)), ‘, y: ‘, num2str(centroid(2))];
frame = insertText(frame, [centroid(1) – 10, centroid(2) – 10], text, ‘FontSize’, 50, ‘TextColor’, [0, 255, 0]);
coordinates = [];
coordinates = [coordinates; centroid];
disp(coordinates);
end
frame = insertText(frame, [10, 10], [‘Pitch: ‘, num2str(pitch), ‘°’], ‘FontSize’, 18, ‘BoxColor’, ‘red’, ‘TextColor’, ‘white’);
frame = insertText(frame, [10, 40], [‘Roll: ‘, num2str(roll), ‘°’], ‘FontSize’, 18, ‘BoxColor’, ‘red’, ‘TextColor’, ‘white’);
frame = insertText(frame, [10, 70], [‘Yaw: ‘, num2str(yaw), ‘°’], ‘FontSize’, 18, ‘BoxColor’, ‘red’, ‘TextColor’, ‘white’);
imshow(frame);
pause(0.0001);
end
clear cap;Hi, Im trying to find the orientation that is roll and pitch angle of my platform by analysing the overall geometery of the dots. To do so i have firstly detected the dots by using standard deviation and k-means clustering and dividing the image into 5×5 boxes then a plane fitting curve method is used to determine the overall geometery of the dots which further gives orientation of the plate. The obtained angles are incorrect what might have possibly gone wrong please help and suggest any possible solution. I’m actually trying to implement a blass on a plate system and i want to detect the orientation of the plate using webcam. Also im using MATLAB 2021a therefore im not sure how to calibrate my camera for such a pattern. The MATLAB code is given below;
clear all;
clc;
close all;
% Create a webcam object
cap = webcam(‘Adesso CyberTrack H3’);
% Adjust camera settings if supported
try
% Set the exposure time (shutter speed) in seconds
exposureTime = 0.01; % Adjust as needed
cap.ExposureMode = ‘manual’;
cap.Exposure = exposureTime;
catch ME
disp(‘Warning: Unable to set exposure time for the camera.’);
disp(ME.message);
end
% Create the background subtractor object for ball detection
back_sub = vision.ForegroundDetector(‘NumTrainingFrames’, 100, ‘NumGaussians’, 3, ‘MinimumBackgroundRatio’, 0.7);
% Create structuring element for morphological operation
se = strel(‘rectangle’, [20, 20]);
% Initialize calibration values
calibration_pitch = 0;
calibration_roll = 0;
% Calibrate the system to set initial pitch and roll to zero
frame = snapshot(cap);
I_gray = rgb2gray(frame);
I_contrast = imadjust(I_gray);
bw = imbinarize(I_contrast, ‘adaptive’);
bw_filled = imfill(bw, ‘holes’);
bw_cleaned = bwareaopen(bw_filled, 50);
stats = regionprops(‘table’, bw_cleaned, ‘Centroid’, ‘BoundingBox’);
centroids = stats.Centroid;
if size(centroids, 1) >= 3
X = centroids(:, 1);
Y = centroids(:, 2);
Z = linspace(0, 1, size(centroids, 1))’;
A = [X, Y, ones(size(X))];
coeffs = A Z;
normal = [-coeffs(1), -coeffs(2), 1];
normal = normal / norm(normal);
calibration_pitch = asin(normal(1));
calibration_roll = asin(normal(2));
disp([‘Calibration Pitch: ‘, num2str(calibration_pitch), ‘ degrees’]);
disp([‘Calibration Roll: ‘, num2str(calibration_roll), ‘ degrees’]);
else
disp(‘Not enough dots detected for calibration.’);
end
while true
% Read frame from webcam
frame = snapshot(cap);
% Part 1: Dot Detection and Tilt Angle Calculation
I_gray = rgb2gray(frame);
I_contrast = imadjust(I_gray);
bw = imbinarize(I_contrast, ‘adaptive’);
bw_filled = imfill(bw, ‘holes’);
bw_cleaned = bwareaopen(bw_filled, 50);
stats = regionprops(‘table’, bw_cleaned, ‘Centroid’, ‘BoundingBox’);
centroids = stats.Centroid;
boundingBoxes = stats.BoundingBox;
if size(centroids, 1) >= 3
X = centroids(:, 1);
Y = centroids(:, 2);
Z = linspace(0, 1, size(centroids, 1))’;
A = [X, Y, ones(size(X))];
coeffs = A Z;
normal = [-coeffs(1), -coeffs(2), 1];
normal = normal / norm(normal);
pitch = asin(normal(1)) – calibration_pitch;
roll = asin(normal(2)) – calibration_roll;
yaw = 0;
disp([‘Pitch (Tilt around Y-axis): ‘, num2str(pitch), ‘ degrees’]);
disp([‘Roll (Tilt around X-axis): ‘, num2str(roll), ‘ degrees’]);
disp([‘Yaw (Rotation around Z-axis): ‘, num2str(yaw), ‘ degrees’]);
else
pitch = 0;
roll = 0;
yaw = 0;
disp(‘Not enough dots detected to fit a plane.’);
end
for i = 1:size(boundingBoxes, 1)
frame = insertShape(frame, ‘Rectangle’, boundingBoxes(i, :), ‘Color’, ‘g’, ‘LineWidth’, 2);
end
fg_mask = step(back_sub, frame);
fg_mask = imclose(fg_mask, se);
fg_mask = medfilt2(fg_mask, [5, 5]);
fg_mask = uint8(fg_mask) * 255;
[contours, ~] = bwlabel(fg_mask);
stats = regionprops(contours, ‘Area’, ‘BoundingBox’, ‘Centroid’);
if ~isempty(stats)
[~, max_index] = max([stats.Area]);
centroid = stats(max_index).Centroid;
boundingBox = stats(max_index).BoundingBox;
frame = insertShape(frame, ‘Rectangle’, boundingBox, ‘Color’, [0, 255, 0], ‘LineWidth’, 3);
text = [‘x: ‘, num2str(centroid(1)), ‘, y: ‘, num2str(centroid(2))];
frame = insertText(frame, [centroid(1) – 10, centroid(2) – 10], text, ‘FontSize’, 50, ‘TextColor’, [0, 255, 0]);
coordinates = [];
coordinates = [coordinates; centroid];
disp(coordinates);
end
frame = insertText(frame, [10, 10], [‘Pitch: ‘, num2str(pitch), ‘°’], ‘FontSize’, 18, ‘BoxColor’, ‘red’, ‘TextColor’, ‘white’);
frame = insertText(frame, [10, 40], [‘Roll: ‘, num2str(roll), ‘°’], ‘FontSize’, 18, ‘BoxColor’, ‘red’, ‘TextColor’, ‘white’);
frame = insertText(frame, [10, 70], [‘Yaw: ‘, num2str(yaw), ‘°’], ‘FontSize’, 18, ‘BoxColor’, ‘red’, ‘TextColor’, ‘white’);
imshow(frame);
pause(0.0001);
end
clear cap; Hi, Im trying to find the orientation that is roll and pitch angle of my platform by analysing the overall geometery of the dots. To do so i have firstly detected the dots by using standard deviation and k-means clustering and dividing the image into 5×5 boxes then a plane fitting curve method is used to determine the overall geometery of the dots which further gives orientation of the plate. The obtained angles are incorrect what might have possibly gone wrong please help and suggest any possible solution. I’m actually trying to implement a blass on a plate system and i want to detect the orientation of the plate using webcam. Also im using MATLAB 2021a therefore im not sure how to calibrate my camera for such a pattern. The MATLAB code is given below;
clear all;
clc;
close all;
% Create a webcam object
cap = webcam(‘Adesso CyberTrack H3’);
% Adjust camera settings if supported
try
% Set the exposure time (shutter speed) in seconds
exposureTime = 0.01; % Adjust as needed
cap.ExposureMode = ‘manual’;
cap.Exposure = exposureTime;
catch ME
disp(‘Warning: Unable to set exposure time for the camera.’);
disp(ME.message);
end
% Create the background subtractor object for ball detection
back_sub = vision.ForegroundDetector(‘NumTrainingFrames’, 100, ‘NumGaussians’, 3, ‘MinimumBackgroundRatio’, 0.7);
% Create structuring element for morphological operation
se = strel(‘rectangle’, [20, 20]);
% Initialize calibration values
calibration_pitch = 0;
calibration_roll = 0;
% Calibrate the system to set initial pitch and roll to zero
frame = snapshot(cap);
I_gray = rgb2gray(frame);
I_contrast = imadjust(I_gray);
bw = imbinarize(I_contrast, ‘adaptive’);
bw_filled = imfill(bw, ‘holes’);
bw_cleaned = bwareaopen(bw_filled, 50);
stats = regionprops(‘table’, bw_cleaned, ‘Centroid’, ‘BoundingBox’);
centroids = stats.Centroid;
if size(centroids, 1) >= 3
X = centroids(:, 1);
Y = centroids(:, 2);
Z = linspace(0, 1, size(centroids, 1))’;
A = [X, Y, ones(size(X))];
coeffs = A Z;
normal = [-coeffs(1), -coeffs(2), 1];
normal = normal / norm(normal);
calibration_pitch = asin(normal(1));
calibration_roll = asin(normal(2));
disp([‘Calibration Pitch: ‘, num2str(calibration_pitch), ‘ degrees’]);
disp([‘Calibration Roll: ‘, num2str(calibration_roll), ‘ degrees’]);
else
disp(‘Not enough dots detected for calibration.’);
end
while true
% Read frame from webcam
frame = snapshot(cap);
% Part 1: Dot Detection and Tilt Angle Calculation
I_gray = rgb2gray(frame);
I_contrast = imadjust(I_gray);
bw = imbinarize(I_contrast, ‘adaptive’);
bw_filled = imfill(bw, ‘holes’);
bw_cleaned = bwareaopen(bw_filled, 50);
stats = regionprops(‘table’, bw_cleaned, ‘Centroid’, ‘BoundingBox’);
centroids = stats.Centroid;
boundingBoxes = stats.BoundingBox;
if size(centroids, 1) >= 3
X = centroids(:, 1);
Y = centroids(:, 2);
Z = linspace(0, 1, size(centroids, 1))’;
A = [X, Y, ones(size(X))];
coeffs = A Z;
normal = [-coeffs(1), -coeffs(2), 1];
normal = normal / norm(normal);
pitch = asin(normal(1)) – calibration_pitch;
roll = asin(normal(2)) – calibration_roll;
yaw = 0;
disp([‘Pitch (Tilt around Y-axis): ‘, num2str(pitch), ‘ degrees’]);
disp([‘Roll (Tilt around X-axis): ‘, num2str(roll), ‘ degrees’]);
disp([‘Yaw (Rotation around Z-axis): ‘, num2str(yaw), ‘ degrees’]);
else
pitch = 0;
roll = 0;
yaw = 0;
disp(‘Not enough dots detected to fit a plane.’);
end
for i = 1:size(boundingBoxes, 1)
frame = insertShape(frame, ‘Rectangle’, boundingBoxes(i, :), ‘Color’, ‘g’, ‘LineWidth’, 2);
end
fg_mask = step(back_sub, frame);
fg_mask = imclose(fg_mask, se);
fg_mask = medfilt2(fg_mask, [5, 5]);
fg_mask = uint8(fg_mask) * 255;
[contours, ~] = bwlabel(fg_mask);
stats = regionprops(contours, ‘Area’, ‘BoundingBox’, ‘Centroid’);
if ~isempty(stats)
[~, max_index] = max([stats.Area]);
centroid = stats(max_index).Centroid;
boundingBox = stats(max_index).BoundingBox;
frame = insertShape(frame, ‘Rectangle’, boundingBox, ‘Color’, [0, 255, 0], ‘LineWidth’, 3);
text = [‘x: ‘, num2str(centroid(1)), ‘, y: ‘, num2str(centroid(2))];
frame = insertText(frame, [centroid(1) – 10, centroid(2) – 10], text, ‘FontSize’, 50, ‘TextColor’, [0, 255, 0]);
coordinates = [];
coordinates = [coordinates; centroid];
disp(coordinates);
end
frame = insertText(frame, [10, 10], [‘Pitch: ‘, num2str(pitch), ‘°’], ‘FontSize’, 18, ‘BoxColor’, ‘red’, ‘TextColor’, ‘white’);
frame = insertText(frame, [10, 40], [‘Roll: ‘, num2str(roll), ‘°’], ‘FontSize’, 18, ‘BoxColor’, ‘red’, ‘TextColor’, ‘white’);
frame = insertText(frame, [10, 70], [‘Yaw: ‘, num2str(yaw), ‘°’], ‘FontSize’, 18, ‘BoxColor’, ‘red’, ‘TextColor’, ‘white’);
imshow(frame);
pause(0.0001);
end
clear cap; matlab, image processing, computer vision MATLAB Answers — New Questions
How to generate a2l (asap2) file for Autosar classic platform with Matlab R2021b?
In Matlab R2021b, the method of generating a2l file is changed. But the new a2l generation tool named Generate Calibration Files suppors only targets like ert, grt and adaptive autosar. It does not support the classic Autosar target.
How to generate a2l (asap2) file for the classic autosar simulink models with Matlab R2021b?In Matlab R2021b, the method of generating a2l file is changed. But the new a2l generation tool named Generate Calibration Files suppors only targets like ert, grt and adaptive autosar. It does not support the classic Autosar target.
How to generate a2l (asap2) file for the classic autosar simulink models with Matlab R2021b? In Matlab R2021b, the method of generating a2l file is changed. But the new a2l generation tool named Generate Calibration Files suppors only targets like ert, grt and adaptive autosar. It does not support the classic Autosar target.
How to generate a2l (asap2) file for the classic autosar simulink models with Matlab R2021b? aspa2, a2l, simulink, r2021b, autosar, classic autosar MATLAB Answers — New Questions
Performance of ode solvers in Matlab and Simulink
I have implemented a simulation of a system with around 20k states in Simulink via a Matlab System using iterpreted execution (since I was lazy, I used simbolic variables in the setupImpl() function for deriving the stepImpl() function more easily). The model simulates rather slow, and thus I am thinking on what to do next to improve performance. I thought about
1) rewrite the matlab system such that I can use code generation for execution
2) use the obj.stepImpl() function in the workspace and call there an ode solver.
Do you have a guess which of the options is going to show better performance? Are there any advantages of both options? Option 2) would be much easier for me to implement.
Thanks in advance!I have implemented a simulation of a system with around 20k states in Simulink via a Matlab System using iterpreted execution (since I was lazy, I used simbolic variables in the setupImpl() function for deriving the stepImpl() function more easily). The model simulates rather slow, and thus I am thinking on what to do next to improve performance. I thought about
1) rewrite the matlab system such that I can use code generation for execution
2) use the obj.stepImpl() function in the workspace and call there an ode solver.
Do you have a guess which of the options is going to show better performance? Are there any advantages of both options? Option 2) would be much easier for me to implement.
Thanks in advance! I have implemented a simulation of a system with around 20k states in Simulink via a Matlab System using iterpreted execution (since I was lazy, I used simbolic variables in the setupImpl() function for deriving the stepImpl() function more easily). The model simulates rather slow, and thus I am thinking on what to do next to improve performance. I thought about
1) rewrite the matlab system such that I can use code generation for execution
2) use the obj.stepImpl() function in the workspace and call there an ode solver.
Do you have a guess which of the options is going to show better performance? Are there any advantages of both options? Option 2) would be much easier for me to implement.
Thanks in advance! ode, simulink, performance, code generation, interpreted execution, matlab system MATLAB Answers — New Questions
Plotting Discrete Time Functions
I need to plot 5 cos(π n /6 – π/2) as a discrete tim signal. But I am not getting the proper result.
n = [-5:0.001:5];
y = 5*cos(pi*(n/2)-(pi/2));
stem(n,y);
What am I missing from this code to get the discrete time signals?I need to plot 5 cos(π n /6 – π/2) as a discrete tim signal. But I am not getting the proper result.
n = [-5:0.001:5];
y = 5*cos(pi*(n/2)-(pi/2));
stem(n,y);
What am I missing from this code to get the discrete time signals? I need to plot 5 cos(π n /6 – π/2) as a discrete tim signal. But I am not getting the proper result.
n = [-5:0.001:5];
y = 5*cos(pi*(n/2)-(pi/2));
stem(n,y);
What am I missing from this code to get the discrete time signals? discrete time signals, functions MATLAB Answers — New Questions
Error occurred while executing the listener callback for event DataWritten defined for class asyncio.InputStream
Hi,
I am reading data over TCP/IP from hardware device using
t1=tcpclient("xxxx",xxxx)
I am configuring callback function, so that when ever 210 data byes avaible to read function1() execute.
while t1.BytesAvailable == 0
%wait for data
end
configureCallback(t1,"byte",210,@varargin()function1())
function function1()
Bytes_DATAF1=t1.NumBytesAvailable
DATA=read(t1,210);
decode=swapbytes(typecast(uint8(DATAF1(1,7:10)’),’uint32′));
Bytes_DATAF2=t1.NumBytesAvailable
end
codes doing fine but in middle giving following warning.
Warning: Error occurred while executing the listener callback for event DataWritten
defined for class asyncio.InputStream:
Error using +
Integers can only be combined with integers of the same class, or scalar doubles.
Error in matlabshared.network.internal.TCPClient/onDataReceived
Error in
matlabshared.network.internal.TCPClient>@(varargin)obj.onDataReceived(varargin{:})
Error in asyncio.Channel/onDataReceived (line 487)
notify(obj.InputStream, ‘DataWritten’, …
Error in asyncio.Channel>@(source,data)obj.onDataReceived() (line 425)
@(source, data) obj.onDataReceived());
> In asyncio/Channel/onDataReceived (line 487)
In asyncio.Channel>@(source,data)obj.onDataReceived() (line 425)
——————————————————————————————————–
function function1()
Bytes_DATAF1=t1.NumBytesAvailable
DATA=read(t1,210);
decode=swapbytes(typecast(uint8(DATAF1(1,7:10)’),’uint32′));
Bytes_DATAF2=t1.NumBytesAvailable
end
bytes availabe to read
t1.BytesAvailable=Bytes_DATAF1 =12810
mycode reads only 210 bytes
bytes remaining to read
t1.BytesAvailable=Bytes_DATAF2 = 255
12810-255=12555 bytes missing.Hi,
I am reading data over TCP/IP from hardware device using
t1=tcpclient("xxxx",xxxx)
I am configuring callback function, so that when ever 210 data byes avaible to read function1() execute.
while t1.BytesAvailable == 0
%wait for data
end
configureCallback(t1,"byte",210,@varargin()function1())
function function1()
Bytes_DATAF1=t1.NumBytesAvailable
DATA=read(t1,210);
decode=swapbytes(typecast(uint8(DATAF1(1,7:10)’),’uint32′));
Bytes_DATAF2=t1.NumBytesAvailable
end
codes doing fine but in middle giving following warning.
Warning: Error occurred while executing the listener callback for event DataWritten
defined for class asyncio.InputStream:
Error using +
Integers can only be combined with integers of the same class, or scalar doubles.
Error in matlabshared.network.internal.TCPClient/onDataReceived
Error in
matlabshared.network.internal.TCPClient>@(varargin)obj.onDataReceived(varargin{:})
Error in asyncio.Channel/onDataReceived (line 487)
notify(obj.InputStream, ‘DataWritten’, …
Error in asyncio.Channel>@(source,data)obj.onDataReceived() (line 425)
@(source, data) obj.onDataReceived());
> In asyncio/Channel/onDataReceived (line 487)
In asyncio.Channel>@(source,data)obj.onDataReceived() (line 425)
——————————————————————————————————–
function function1()
Bytes_DATAF1=t1.NumBytesAvailable
DATA=read(t1,210);
decode=swapbytes(typecast(uint8(DATAF1(1,7:10)’),’uint32′));
Bytes_DATAF2=t1.NumBytesAvailable
end
bytes availabe to read
t1.BytesAvailable=Bytes_DATAF1 =12810
mycode reads only 210 bytes
bytes remaining to read
t1.BytesAvailable=Bytes_DATAF2 = 255
12810-255=12555 bytes missing. Hi,
I am reading data over TCP/IP from hardware device using
t1=tcpclient("xxxx",xxxx)
I am configuring callback function, so that when ever 210 data byes avaible to read function1() execute.
while t1.BytesAvailable == 0
%wait for data
end
configureCallback(t1,"byte",210,@varargin()function1())
function function1()
Bytes_DATAF1=t1.NumBytesAvailable
DATA=read(t1,210);
decode=swapbytes(typecast(uint8(DATAF1(1,7:10)’),’uint32′));
Bytes_DATAF2=t1.NumBytesAvailable
end
codes doing fine but in middle giving following warning.
Warning: Error occurred while executing the listener callback for event DataWritten
defined for class asyncio.InputStream:
Error using +
Integers can only be combined with integers of the same class, or scalar doubles.
Error in matlabshared.network.internal.TCPClient/onDataReceived
Error in
matlabshared.network.internal.TCPClient>@(varargin)obj.onDataReceived(varargin{:})
Error in asyncio.Channel/onDataReceived (line 487)
notify(obj.InputStream, ‘DataWritten’, …
Error in asyncio.Channel>@(source,data)obj.onDataReceived() (line 425)
@(source, data) obj.onDataReceived());
> In asyncio/Channel/onDataReceived (line 487)
In asyncio.Channel>@(source,data)obj.onDataReceived() (line 425)
——————————————————————————————————–
function function1()
Bytes_DATAF1=t1.NumBytesAvailable
DATA=read(t1,210);
decode=swapbytes(typecast(uint8(DATAF1(1,7:10)’),’uint32′));
Bytes_DATAF2=t1.NumBytesAvailable
end
bytes availabe to read
t1.BytesAvailable=Bytes_DATAF1 =12810
mycode reads only 210 bytes
bytes remaining to read
t1.BytesAvailable=Bytes_DATAF2 = 255
12810-255=12555 bytes missing. tcpclient, callback, configurecallback MATLAB Answers — New Questions
What principles does the accumulator for storing data (output or intermediate) follow after converting the model into C code using a C coder?
For example, is the upper limit of i in the for loop automatically generated based on factors such as the size of the data or something else?I would like to interrupt the process of generating data into smaller segments as per my request, but I don’t know how to handle these data or intermediate quantities because I am concerned that interrupting this process directly may lead to uncontrollable issues such as data leakage or data coverage。For example, is the upper limit of i in the for loop automatically generated based on factors such as the size of the data or something else?I would like to interrupt the process of generating data into smaller segments as per my request, but I don’t know how to handle these data or intermediate quantities because I am concerned that interrupting this process directly may lead to uncontrollable issues such as data leakage or data coverage。 For example, is the upper limit of i in the for loop automatically generated based on factors such as the size of the data or something else?I would like to interrupt the process of generating data into smaller segments as per my request, but I don’t know how to handle these data or intermediate quantities because I am concerned that interrupting this process directly may lead to uncontrollable issues such as data leakage or data coverage。 simulink, signal MATLAB Answers — New Questions
Why do I receive “Error in port widths or dimensions”?
I have a system as shown in the picture. y is a scalar defined in the function(also shown in picture).
However I have received such errors. Why is this happening?
Error in port widths or dimensions. Invalid dimension has been specified for ‘input port 2’ of ‘slxlx/Add’.
Error in port widths or dimensions. ‘output port 1’ of ‘slxlx/Transfer Fcn’ is a one dimensional vector with 1 elements.I have a system as shown in the picture. y is a scalar defined in the function(also shown in picture).
However I have received such errors. Why is this happening?
Error in port widths or dimensions. Invalid dimension has been specified for ‘input port 2’ of ‘slxlx/Add’.
Error in port widths or dimensions. ‘output port 1’ of ‘slxlx/Transfer Fcn’ is a one dimensional vector with 1 elements. I have a system as shown in the picture. y is a scalar defined in the function(also shown in picture).
However I have received such errors. Why is this happening?
Error in port widths or dimensions. Invalid dimension has been specified for ‘input port 2’ of ‘slxlx/Add’.
Error in port widths or dimensions. ‘output port 1’ of ‘slxlx/Transfer Fcn’ is a one dimensional vector with 1 elements. add, matlab, simulink, sum, dimension, width MATLAB Answers — New Questions
Functions of APP cannot jump in APP Designer of Matlab R2023b
When I select a app function, and click "Open", nothing happened, but I can open external fucntion successfully.When I select a app function, and click "Open", nothing happened, but I can open external fucntion successfully. When I select a app function, and click "Open", nothing happened, but I can open external fucntion successfully. bug, app designer MATLAB Answers — New Questions
Load external file in ssc block Simscape
I build a "liquid valve" component (.ssc file) in Simscape which includes a dropdown menu to select different valve types. The parameters for each valve are stored as a structure in a separated .m file. Depending on which valve is selected, I would like to "load" the corresponding values into my "liquid valve" component (.ssc file). Similar to the "Thermal Liquid Properties (TL)" component which loads an external file depending on the selected fluid.
How do I "load/import" my external .m file (structure) into my simscape component?I build a "liquid valve" component (.ssc file) in Simscape which includes a dropdown menu to select different valve types. The parameters for each valve are stored as a structure in a separated .m file. Depending on which valve is selected, I would like to "load" the corresponding values into my "liquid valve" component (.ssc file). Similar to the "Thermal Liquid Properties (TL)" component which loads an external file depending on the selected fluid.
How do I "load/import" my external .m file (structure) into my simscape component? I build a "liquid valve" component (.ssc file) in Simscape which includes a dropdown menu to select different valve types. The parameters for each valve are stored as a structure in a separated .m file. Depending on which valve is selected, I would like to "load" the corresponding values into my "liquid valve" component (.ssc file). Similar to the "Thermal Liquid Properties (TL)" component which loads an external file depending on the selected fluid.
How do I "load/import" my external .m file (structure) into my simscape component? simscape, structures MATLAB Answers — New Questions
Getting error Index exceesds the numbers of array elements. Index must not exceeds 4 getting this error when calling the function in Runfile. Secondly needs help to modified
Getting error Index exceesds the numbers of array elements. Index must not exceeds 4 getting this error when calling the function in Runfile. Secondly needs help to modified this app in where we give different values of RLC in one edit field and also the time interval innone edit field.Getting error Index exceesds the numbers of array elements. Index must not exceeds 4 getting this error when calling the function in Runfile. Secondly needs help to modified this app in where we give different values of RLC in one edit field and also the time interval innone edit field. Getting error Index exceesds the numbers of array elements. Index must not exceeds 4 getting this error when calling the function in Runfile. Secondly needs help to modified this app in where we give different values of RLC in one edit field and also the time interval innone edit field. matlab MATLAB Answers — New Questions
Does the new MatLab update integrate features of Psychtoolbox, making it possibly unnecessary for psychology research?
I work in a visual attention lab, and we use Matlab to code lots of experiments that show many pictures with different timings, features, etc. However, our lab computers are all Mac OSs, so we’re concerned that Psychtoolbox will be essentially useless once we are required to update the OS by the institution. Are the new Matlab updates moving towards making it powerful enough to code these experiments without needing psychtoolbox?I work in a visual attention lab, and we use Matlab to code lots of experiments that show many pictures with different timings, features, etc. However, our lab computers are all Mac OSs, so we’re concerned that Psychtoolbox will be essentially useless once we are required to update the OS by the institution. Are the new Matlab updates moving towards making it powerful enough to code these experiments without needing psychtoolbox? I work in a visual attention lab, and we use Matlab to code lots of experiments that show many pictures with different timings, features, etc. However, our lab computers are all Mac OSs, so we’re concerned that Psychtoolbox will be essentially useless once we are required to update the OS by the institution. Are the new Matlab updates moving towards making it powerful enough to code these experiments without needing psychtoolbox? psychtoolbox, updates, matlab MATLAB Answers — New Questions
Simulink user interface slow
Greetings,
Using MATLAB/Simulink 2019b. The interface while modifying my model can get really slow and laggy. Even just simply clicking, dragging, and resizing. Scrolling the wheel to zoom in/zoom out, along with attaching connections.
Is there anything I can do to increase the performance. My laptop isn’t the newest, but it’s also not that old. I use 64b windows 10, 64b MATLAB. I’m at 10/16 GB of memory used with MATLAB taking 1.5GB and a constant 15-25% CPU.
I have two models open, and some MATLAB code. Really would appreciate any advice on increasing the general UI performance.
Edit: Restarted MATLAB. without a model open it idles with 0% CPU. When I open the model it "idles" at 10+% CPU. Just having the model open and not interacting with it.Greetings,
Using MATLAB/Simulink 2019b. The interface while modifying my model can get really slow and laggy. Even just simply clicking, dragging, and resizing. Scrolling the wheel to zoom in/zoom out, along with attaching connections.
Is there anything I can do to increase the performance. My laptop isn’t the newest, but it’s also not that old. I use 64b windows 10, 64b MATLAB. I’m at 10/16 GB of memory used with MATLAB taking 1.5GB and a constant 15-25% CPU.
I have two models open, and some MATLAB code. Really would appreciate any advice on increasing the general UI performance.
Edit: Restarted MATLAB. without a model open it idles with 0% CPU. When I open the model it "idles" at 10+% CPU. Just having the model open and not interacting with it. Greetings,
Using MATLAB/Simulink 2019b. The interface while modifying my model can get really slow and laggy. Even just simply clicking, dragging, and resizing. Scrolling the wheel to zoom in/zoom out, along with attaching connections.
Is there anything I can do to increase the performance. My laptop isn’t the newest, but it’s also not that old. I use 64b windows 10, 64b MATLAB. I’m at 10/16 GB of memory used with MATLAB taking 1.5GB and a constant 15-25% CPU.
I have two models open, and some MATLAB code. Really would appreciate any advice on increasing the general UI performance.
Edit: Restarted MATLAB. without a model open it idles with 0% CPU. When I open the model it "idles" at 10+% CPU. Just having the model open and not interacting with it. performance ui MATLAB Answers — New Questions
Export function is saving previous result of matlab live script
Export function is saving previous result of matlab live script, and saving it is loosing all the data when overwritten.
I have a matlab live script file, and export function is included in that, however it is not saving the current run data.
is there any way to export the only data of the current state of matlab live script?Export function is saving previous result of matlab live script, and saving it is loosing all the data when overwritten.
I have a matlab live script file, and export function is included in that, however it is not saving the current run data.
is there any way to export the only data of the current state of matlab live script? Export function is saving previous result of matlab live script, and saving it is loosing all the data when overwritten.
I have a matlab live script file, and export function is included in that, however it is not saving the current run data.
is there any way to export the only data of the current state of matlab live script? export, save MATLAB Answers — New Questions
how to draw a 5×5 three-dimensional planar array with isotropic elements using the formula AF_(n ) (θ,ϕ)= {1/M sin(M/2 ψ_x )/sin(ψ_x/2) }{1/N sin(N/2 ψ_y )/sin(ψ_y/2) }
seperti gambar berikutseperti gambar berikut seperti gambar berikut @all MATLAB Answers — New Questions
is it possible to restart progress of self-paced course
Started learning MATLAB Fundamentals then stopped for a few months. Would like to start again.Started learning MATLAB Fundamentals then stopped for a few months. Would like to start again. Started learning MATLAB Fundamentals then stopped for a few months. Would like to start again. matlab MATLAB Answers — New Questions