Author: PuTI
Error 5201. Installation not associated with my account.
I have installed MatLab and associated my academic license but when I try to open it I get the message ‘Error 5201’. I have tried to solve it following the steps indicated in ‘Help’ – reinstall it, disable antivirus and firewall – but it doesn’t work. According to MathWorks there are no activations: the installation is not associated to my account. However I have the application on my computer and the folder with all the corresponding files including the license and executables.
I don’t know how to continue at this point.I have installed MatLab and associated my academic license but when I try to open it I get the message ‘Error 5201’. I have tried to solve it following the steps indicated in ‘Help’ – reinstall it, disable antivirus and firewall – but it doesn’t work. According to MathWorks there are no activations: the installation is not associated to my account. However I have the application on my computer and the folder with all the corresponding files including the license and executables.
I don’t know how to continue at this point. I have installed MatLab and associated my academic license but when I try to open it I get the message ‘Error 5201’. I have tried to solve it following the steps indicated in ‘Help’ – reinstall it, disable antivirus and firewall – but it doesn’t work. According to MathWorks there are no activations: the installation is not associated to my account. However I have the application on my computer and the folder with all the corresponding files including the license and executables.
I don’t know how to continue at this point. error 5201, activations, installation, licensing MATLAB Answers — New Questions
Figures are not saving as the correct size when put into a PDF
Please, I would appreciate any help as I have been stuck on this question for days. I have coded a loop that takes images from a folder and puts them in a 2×2 table and automatically numbers them. It creates a figure with the four images on it. It repeats this process until all the images have been used. Then it creates a PDF with all the figures saved, e.g. one figure of four images per page. My issue is, I need the figures to be in the centre of a landscape page, with white space margins around this. Currently, the images look fine on the figure display when you run the code, but when I open up the PDF, they take up the entire page and leave no margin space. I’ll insert two images of what I currently get, and what I need to produce. I would be so so appreciative of anyone that can help me please. Each image needs to be 10cm width by 7cm height on a landscape page in the final PDF.
Coding is not my strongest suit so I apologise if I have mistakenly used the wrong terminology. Thank you in advance.
Here’s the relevant parts of my code.
% Define the desired figure size in inches
figureWidth = 11.7; % Total width of the figure in inches
figureHeight = 8.3; % Total height of the figure in inches
% Define the desired image size in centimeters
imageWidth_cm = 10; % Width of each image in centimeters
imageHeight_cm = 7.5; % Height of each image in centimeters
% Convert image size from centimeters to inches
imageWidth_inch = imageWidth_cm / 2.54; % Convert cm to inches
imageHeight_inch = imageHeight_cm / 2.54; % Convert cm to inches
% Define the spacing between images (in inches)
horizontalSpacing = 0.5; % Spacing between images horizontally
verticalSpacing = 0.5; % Spacing between images vertically
% Calculate the total width and height required for the 2×2 grid
totalWidth = 2 * imageWidth_inch + horizontalSpacing;
totalHeight = 2 * imageHeight_inch + verticalSpacing;
% Calculate the left and bottom margins to center the grid
leftMargin = (figureWidth – totalWidth) / 2;
bottomMargin = (figureHeight – totalHeight) / 2;
% Initialize a cell array to store figure handles
figures = cell(numTables, 1);
% Calculate the position of the subplot
subplotX = leftMargin + mod(i – 1, 2) * (imageWidth_inch + horizontalSpacing);
subplotY = bottomMargin + floor((i – 1) / 2) * (imageHeight_inch + verticalSpacing);
% Create a subplot for each image
axes(‘Position’, [subplotX / figureWidth, subplotY / figureHeight, imageWidth_inch / figureWidth, imageHeight_inch / figureHeight]);
imshow(img);
axis off;
% Save the figure as a high-resolution image
outputFileName = fullfile(outputFolder, [‘Figure_’, num2str(tableIdx), ‘.png’]);
exportgraphics(fig, outputFileName, ‘Resolution’, 300);
outputPDF = fullfile(outputFolder, ‘output.pdf’); % Define the output PDF file
for i = 1:numTables
% Export the figure to the PDF
exportgraphics(figures{i}, outputPDF, ‘Resolution’, 300, ‘Append’, i > 1, ‘ContentType’, ‘vector’, ‘Padding’, 0.5);
endPlease, I would appreciate any help as I have been stuck on this question for days. I have coded a loop that takes images from a folder and puts them in a 2×2 table and automatically numbers them. It creates a figure with the four images on it. It repeats this process until all the images have been used. Then it creates a PDF with all the figures saved, e.g. one figure of four images per page. My issue is, I need the figures to be in the centre of a landscape page, with white space margins around this. Currently, the images look fine on the figure display when you run the code, but when I open up the PDF, they take up the entire page and leave no margin space. I’ll insert two images of what I currently get, and what I need to produce. I would be so so appreciative of anyone that can help me please. Each image needs to be 10cm width by 7cm height on a landscape page in the final PDF.
Coding is not my strongest suit so I apologise if I have mistakenly used the wrong terminology. Thank you in advance.
Here’s the relevant parts of my code.
% Define the desired figure size in inches
figureWidth = 11.7; % Total width of the figure in inches
figureHeight = 8.3; % Total height of the figure in inches
% Define the desired image size in centimeters
imageWidth_cm = 10; % Width of each image in centimeters
imageHeight_cm = 7.5; % Height of each image in centimeters
% Convert image size from centimeters to inches
imageWidth_inch = imageWidth_cm / 2.54; % Convert cm to inches
imageHeight_inch = imageHeight_cm / 2.54; % Convert cm to inches
% Define the spacing between images (in inches)
horizontalSpacing = 0.5; % Spacing between images horizontally
verticalSpacing = 0.5; % Spacing between images vertically
% Calculate the total width and height required for the 2×2 grid
totalWidth = 2 * imageWidth_inch + horizontalSpacing;
totalHeight = 2 * imageHeight_inch + verticalSpacing;
% Calculate the left and bottom margins to center the grid
leftMargin = (figureWidth – totalWidth) / 2;
bottomMargin = (figureHeight – totalHeight) / 2;
% Initialize a cell array to store figure handles
figures = cell(numTables, 1);
% Calculate the position of the subplot
subplotX = leftMargin + mod(i – 1, 2) * (imageWidth_inch + horizontalSpacing);
subplotY = bottomMargin + floor((i – 1) / 2) * (imageHeight_inch + verticalSpacing);
% Create a subplot for each image
axes(‘Position’, [subplotX / figureWidth, subplotY / figureHeight, imageWidth_inch / figureWidth, imageHeight_inch / figureHeight]);
imshow(img);
axis off;
% Save the figure as a high-resolution image
outputFileName = fullfile(outputFolder, [‘Figure_’, num2str(tableIdx), ‘.png’]);
exportgraphics(fig, outputFileName, ‘Resolution’, 300);
outputPDF = fullfile(outputFolder, ‘output.pdf’); % Define the output PDF file
for i = 1:numTables
% Export the figure to the PDF
exportgraphics(figures{i}, outputPDF, ‘Resolution’, 300, ‘Append’, i > 1, ‘ContentType’, ‘vector’, ‘Padding’, 0.5);
end Please, I would appreciate any help as I have been stuck on this question for days. I have coded a loop that takes images from a folder and puts them in a 2×2 table and automatically numbers them. It creates a figure with the four images on it. It repeats this process until all the images have been used. Then it creates a PDF with all the figures saved, e.g. one figure of four images per page. My issue is, I need the figures to be in the centre of a landscape page, with white space margins around this. Currently, the images look fine on the figure display when you run the code, but when I open up the PDF, they take up the entire page and leave no margin space. I’ll insert two images of what I currently get, and what I need to produce. I would be so so appreciative of anyone that can help me please. Each image needs to be 10cm width by 7cm height on a landscape page in the final PDF.
Coding is not my strongest suit so I apologise if I have mistakenly used the wrong terminology. Thank you in advance.
Here’s the relevant parts of my code.
% Define the desired figure size in inches
figureWidth = 11.7; % Total width of the figure in inches
figureHeight = 8.3; % Total height of the figure in inches
% Define the desired image size in centimeters
imageWidth_cm = 10; % Width of each image in centimeters
imageHeight_cm = 7.5; % Height of each image in centimeters
% Convert image size from centimeters to inches
imageWidth_inch = imageWidth_cm / 2.54; % Convert cm to inches
imageHeight_inch = imageHeight_cm / 2.54; % Convert cm to inches
% Define the spacing between images (in inches)
horizontalSpacing = 0.5; % Spacing between images horizontally
verticalSpacing = 0.5; % Spacing between images vertically
% Calculate the total width and height required for the 2×2 grid
totalWidth = 2 * imageWidth_inch + horizontalSpacing;
totalHeight = 2 * imageHeight_inch + verticalSpacing;
% Calculate the left and bottom margins to center the grid
leftMargin = (figureWidth – totalWidth) / 2;
bottomMargin = (figureHeight – totalHeight) / 2;
% Initialize a cell array to store figure handles
figures = cell(numTables, 1);
% Calculate the position of the subplot
subplotX = leftMargin + mod(i – 1, 2) * (imageWidth_inch + horizontalSpacing);
subplotY = bottomMargin + floor((i – 1) / 2) * (imageHeight_inch + verticalSpacing);
% Create a subplot for each image
axes(‘Position’, [subplotX / figureWidth, subplotY / figureHeight, imageWidth_inch / figureWidth, imageHeight_inch / figureHeight]);
imshow(img);
axis off;
% Save the figure as a high-resolution image
outputFileName = fullfile(outputFolder, [‘Figure_’, num2str(tableIdx), ‘.png’]);
exportgraphics(fig, outputFileName, ‘Resolution’, 300);
outputPDF = fullfile(outputFolder, ‘output.pdf’); % Define the output PDF file
for i = 1:numTables
% Export the figure to the PDF
exportgraphics(figures{i}, outputPDF, ‘Resolution’, 300, ‘Append’, i > 1, ‘ContentType’, ‘vector’, ‘Padding’, 0.5);
end pdf, size, image, figure, output, merge MATLAB Answers — New Questions
how can I switc between three systems of ODEs basing on the value of the second solution of each system, and repeat the cycle ?
I have three systems of differential equations, each systemt consists of ten equations, and the first system has initial conditions.
I want to automate the solution and switching between these systems where:
When the value of the second solution of the first system reaches a certain value (symbolised by T_b), the solution of the first system stops and the solution of the second system begins, whose initial conditions are the final conditions of the first system.
When the value of the second solution of the second system reaches a value less than T_b, the solution of the second system stops and the solution of the third system starts, whose initial conditions are the final conditions of the second system.
when finish this , repeat the cycle untill finishin the time spane (200 hours).I have three systems of differential equations, each systemt consists of ten equations, and the first system has initial conditions.
I want to automate the solution and switching between these systems where:
When the value of the second solution of the first system reaches a certain value (symbolised by T_b), the solution of the first system stops and the solution of the second system begins, whose initial conditions are the final conditions of the first system.
When the value of the second solution of the second system reaches a value less than T_b, the solution of the second system stops and the solution of the third system starts, whose initial conditions are the final conditions of the second system.
when finish this , repeat the cycle untill finishin the time spane (200 hours). I have three systems of differential equations, each systemt consists of ten equations, and the first system has initial conditions.
I want to automate the solution and switching between these systems where:
When the value of the second solution of the first system reaches a certain value (symbolised by T_b), the solution of the first system stops and the solution of the second system begins, whose initial conditions are the final conditions of the first system.
When the value of the second solution of the second system reaches a value less than T_b, the solution of the second system stops and the solution of the third system starts, whose initial conditions are the final conditions of the second system.
when finish this , repeat the cycle untill finishin the time spane (200 hours). switch, odes system MATLAB Answers — New Questions
Unable to Extract Numbers Using OCR Despite Performing Image Processing
I have images from a screen recording from which I am trying extract certain text and numbers.
I then crop the regions of interest (ROI) and proceed to resize the image from each ROI. Finally I apply various processing techniques such as filtering, adaptive histogram equalization, masking, binarization and morphological operations as shown below.
My code is shared as under
function [final_frame,point_cloud_block_values] = block_extractor_v10(img)
%% Define Region of Interest
a0 = 25;
for dd = 1:25
a_n(dd) = a0+45*(dd-1);
end
roi_matrix = [360.*ones(25,1),a_n’,67.*ones(25,1),32.*ones(25,1)];
roi3 = [111.51,1099.51,172.98,43.98]; %Final frame name
point_cloud_block_values = zeros(25,1);
for gg = 1:25
I2 = imcrop(img,roi_matrix(gg,:));
I3 = imresize(I2,[33*63,68*68]);
txt1 = ocr(I3,CharacterSet="0123456789",LayoutAnalysis="line");
temp = str2double(txt1.Words);
if isempty(temp)||txt1.TextLineConfidences <0.5
txt1 = ocr(I2,CharacterSet="0123456789",LayoutAnalysis="line");
temp = str2double(txt1.Words);
if isempty(temp)||txt1.TextLineConfidences <0.5
I3 = imresize(I2,[33*70,68*80]);
txt1 = ocr(I3,CharacterSet="0123456789",LayoutAnalysis="line");
temp = str2double(txt1.Words);
end
end
if isempty(temp)||temp>12000
I3_average1 = rgb2gray(I3);
mask = I3_average1 < 60;
mask = imclose(mask, true(9, 5));
txt1 = ocr(mask,CharacterSet="0123456789",LayoutAnalysis="line");
temp = str2double(txt1.Words);
if isempty(temp)
txt1 = ocr(I2,CharacterSet="0123456789",LayoutAnalysis="line");
temp = str2double(txt1.Words);
end
end
if isempty(temp)||size(temp,1)>1
I3_average1 = rgb2gray(I3);
I3_filt = medfilt2(I3_average1);
I3_filt = adapthisteq(I3_filt);
se = strel(‘disk’,1);
I3_filt = imopen(I3_filt,se);
I3_filt = imbinarize(I3_filt);
txt1 = ocr(I3_filt,CharacterSet="0123456789",LayoutAnalysis="line");
temp = str2double(txt1.Words);
end
point_cloud_block_values(gg) = temp;
end
txt3 = ocr(img,roi3,CharacterSet="_aeFmr0123456789",LayoutAnalysis="line");
if length(point_cloud_block_values) ~=25
error(‘The length of each block must be 25’)
end
final_frame = txt3.Words;
final_frame = char(final_frame);
end
However, I am unable to get 100% accuracy in text detection as there are several instances where the text is incorrectly identified by OCR as shown below.
I have uploaded the entire image database on my my google drive. Please adviseI have images from a screen recording from which I am trying extract certain text and numbers.
I then crop the regions of interest (ROI) and proceed to resize the image from each ROI. Finally I apply various processing techniques such as filtering, adaptive histogram equalization, masking, binarization and morphological operations as shown below.
My code is shared as under
function [final_frame,point_cloud_block_values] = block_extractor_v10(img)
%% Define Region of Interest
a0 = 25;
for dd = 1:25
a_n(dd) = a0+45*(dd-1);
end
roi_matrix = [360.*ones(25,1),a_n’,67.*ones(25,1),32.*ones(25,1)];
roi3 = [111.51,1099.51,172.98,43.98]; %Final frame name
point_cloud_block_values = zeros(25,1);
for gg = 1:25
I2 = imcrop(img,roi_matrix(gg,:));
I3 = imresize(I2,[33*63,68*68]);
txt1 = ocr(I3,CharacterSet="0123456789",LayoutAnalysis="line");
temp = str2double(txt1.Words);
if isempty(temp)||txt1.TextLineConfidences <0.5
txt1 = ocr(I2,CharacterSet="0123456789",LayoutAnalysis="line");
temp = str2double(txt1.Words);
if isempty(temp)||txt1.TextLineConfidences <0.5
I3 = imresize(I2,[33*70,68*80]);
txt1 = ocr(I3,CharacterSet="0123456789",LayoutAnalysis="line");
temp = str2double(txt1.Words);
end
end
if isempty(temp)||temp>12000
I3_average1 = rgb2gray(I3);
mask = I3_average1 < 60;
mask = imclose(mask, true(9, 5));
txt1 = ocr(mask,CharacterSet="0123456789",LayoutAnalysis="line");
temp = str2double(txt1.Words);
if isempty(temp)
txt1 = ocr(I2,CharacterSet="0123456789",LayoutAnalysis="line");
temp = str2double(txt1.Words);
end
end
if isempty(temp)||size(temp,1)>1
I3_average1 = rgb2gray(I3);
I3_filt = medfilt2(I3_average1);
I3_filt = adapthisteq(I3_filt);
se = strel(‘disk’,1);
I3_filt = imopen(I3_filt,se);
I3_filt = imbinarize(I3_filt);
txt1 = ocr(I3_filt,CharacterSet="0123456789",LayoutAnalysis="line");
temp = str2double(txt1.Words);
end
point_cloud_block_values(gg) = temp;
end
txt3 = ocr(img,roi3,CharacterSet="_aeFmr0123456789",LayoutAnalysis="line");
if length(point_cloud_block_values) ~=25
error(‘The length of each block must be 25’)
end
final_frame = txt3.Words;
final_frame = char(final_frame);
end
However, I am unable to get 100% accuracy in text detection as there are several instances where the text is incorrectly identified by OCR as shown below.
I have uploaded the entire image database on my my google drive. Please advise I have images from a screen recording from which I am trying extract certain text and numbers.
I then crop the regions of interest (ROI) and proceed to resize the image from each ROI. Finally I apply various processing techniques such as filtering, adaptive histogram equalization, masking, binarization and morphological operations as shown below.
My code is shared as under
function [final_frame,point_cloud_block_values] = block_extractor_v10(img)
%% Define Region of Interest
a0 = 25;
for dd = 1:25
a_n(dd) = a0+45*(dd-1);
end
roi_matrix = [360.*ones(25,1),a_n’,67.*ones(25,1),32.*ones(25,1)];
roi3 = [111.51,1099.51,172.98,43.98]; %Final frame name
point_cloud_block_values = zeros(25,1);
for gg = 1:25
I2 = imcrop(img,roi_matrix(gg,:));
I3 = imresize(I2,[33*63,68*68]);
txt1 = ocr(I3,CharacterSet="0123456789",LayoutAnalysis="line");
temp = str2double(txt1.Words);
if isempty(temp)||txt1.TextLineConfidences <0.5
txt1 = ocr(I2,CharacterSet="0123456789",LayoutAnalysis="line");
temp = str2double(txt1.Words);
if isempty(temp)||txt1.TextLineConfidences <0.5
I3 = imresize(I2,[33*70,68*80]);
txt1 = ocr(I3,CharacterSet="0123456789",LayoutAnalysis="line");
temp = str2double(txt1.Words);
end
end
if isempty(temp)||temp>12000
I3_average1 = rgb2gray(I3);
mask = I3_average1 < 60;
mask = imclose(mask, true(9, 5));
txt1 = ocr(mask,CharacterSet="0123456789",LayoutAnalysis="line");
temp = str2double(txt1.Words);
if isempty(temp)
txt1 = ocr(I2,CharacterSet="0123456789",LayoutAnalysis="line");
temp = str2double(txt1.Words);
end
end
if isempty(temp)||size(temp,1)>1
I3_average1 = rgb2gray(I3);
I3_filt = medfilt2(I3_average1);
I3_filt = adapthisteq(I3_filt);
se = strel(‘disk’,1);
I3_filt = imopen(I3_filt,se);
I3_filt = imbinarize(I3_filt);
txt1 = ocr(I3_filt,CharacterSet="0123456789",LayoutAnalysis="line");
temp = str2double(txt1.Words);
end
point_cloud_block_values(gg) = temp;
end
txt3 = ocr(img,roi3,CharacterSet="_aeFmr0123456789",LayoutAnalysis="line");
if length(point_cloud_block_values) ~=25
error(‘The length of each block must be 25’)
end
final_frame = txt3.Words;
final_frame = char(final_frame);
end
However, I am unable to get 100% accuracy in text detection as there are several instances where the text is incorrectly identified by OCR as shown below.
I have uploaded the entire image database on my my google drive. Please advise ocr, image processing, textscan MATLAB Answers — New Questions
Error: Invalid expression. When calling a function or indexing a variable, use parentheses. Otherwise, check for mismatched delimiters.
Hey guys
I’ve written some code to compute cost function at various theta, as follows:
h = X * theta;
J = [1/(2*m)] * sum[(h-y).^2];
All variables have been defined. Upon running the code above, I’m getting the following error message:
Error: Invalid expression. When calling a function or indexing a variable, use parentheses. Otherwise, check for mismatched delimiters.
I have no experience with Matlab, so any help would be appreciated!
ThanksHey guys
I’ve written some code to compute cost function at various theta, as follows:
h = X * theta;
J = [1/(2*m)] * sum[(h-y).^2];
All variables have been defined. Upon running the code above, I’m getting the following error message:
Error: Invalid expression. When calling a function or indexing a variable, use parentheses. Otherwise, check for mismatched delimiters.
I have no experience with Matlab, so any help would be appreciated!
Thanks Hey guys
I’ve written some code to compute cost function at various theta, as follows:
h = X * theta;
J = [1/(2*m)] * sum[(h-y).^2];
All variables have been defined. Upon running the code above, I’m getting the following error message:
Error: Invalid expression. When calling a function or indexing a variable, use parentheses. Otherwise, check for mismatched delimiters.
I have no experience with Matlab, so any help would be appreciated!
Thanks error MATLAB Answers — New Questions
I have an excel file with 5 columns X1/X2/X3/X4/X5 how to I plot 4 plots (X1,X2;X1,X3;X1;X4;X1;X5) on the same figure using the subplot command.
Do I use xlsreadDo I use xlsread Do I use xlsread subplot MATLAB Answers — New Questions
Supply Chain Security Risk: GitHub Action tj-actions/changed-files Compromised
On March 14th, 2025, security researchers discovered a critical software supply chain vulnerability in the widely-used GitHub Action tj-actions/changed-files
(CVE-2025-30066). This vulnerability allows remote attackers to expose CI/CD secrets via the action’s build logs. The issue affects users who rely on the tj-actions/changed-files
action in GitHub workflows to track changed files within a pull request.
Due to the compromised action, sensitive CI/CD secrets are being inadvertently logged in the GitHub Actions build logs. If these logs are publicly accessible, such as in public repositories, unauthorized users could access and retrieve the clear text secrets. However, there is no evidence suggesting that the exposed secrets were transmitted to any external network.
On March 14th, 2025, security researchers discovered a critical software supply chain vulnerability in the widely-used GitHub Action tj-actions/changed-files (CVE-2025-30066). This vulnerability allows remote attackers to expose CI/CD secrets via the action’s build logs. The issue affects users who rely on the tj-actions/changed-files action in GitHub workflows to track changed files within a pull request.
Due to the compromised action, sensitive CI/CD secrets are being inadvertently logged in the GitHub Actions build logs. If these logs are publicly accessible, such as in public repositories, unauthorized users could access and retrieve the clear text secrets. However, there is no evidence suggesting that the exposed secrets were transmitted to any external network.Read More
I have the error “Unexepected Matlab expression”, how can I solve it ?
Hi everyone, I’m trying to build a custom block with the following code :
component pelton_turbine
% Ce composant calcule le couple généré par l’eau sur la turbine.
% 🔹 Déclaration des ports
nodes
H = foundation.hydraulic.hydraulic; % Port hydraulique
R = foundation.mechanical.rotational.rotational; % Port mécanique rotatif
end
% 🔹 Déclaration des paramètres
parameters
eta = {0.85, ‘1’}; % Rendement de la turbine
rho = {1000, ‘kg/m^3’}; % Densité de l’eau
r = {0.5, ‘m’}; % Rayon moyen de la roue
end
% 🔹 Déclaration des variables internes
variables
T = {0, ‘N*m’}; % Couple généré
Q = {0, ‘m^3/s’}; % Débit volumique
H_head = {0, ‘m’}; % Hauteur d’eau équivalente
end
% 🔹 Bloc des équations
equations
Q == H.q; % Débit entrant dans le port hydraulique
H_head == H.p / (rho * 9.81); % Calcul de la hauteur d’eau équivalente
T == eta * rho * Q * H_head * r; % Formule du couple hydraulique
R.tau == T; % Appliquer le couple sur l’axe mécanique
end
endcomponent
I keep having the same error : Unexepected Matlab expression for the last line (‘endcomponent’). I have already checked a lot of sources of error (hidden spaces, checking that the path is good…). Do you have any idea of what might be wrong ?
Thanks in advance,
NilsHi everyone, I’m trying to build a custom block with the following code :
component pelton_turbine
% Ce composant calcule le couple généré par l’eau sur la turbine.
% 🔹 Déclaration des ports
nodes
H = foundation.hydraulic.hydraulic; % Port hydraulique
R = foundation.mechanical.rotational.rotational; % Port mécanique rotatif
end
% 🔹 Déclaration des paramètres
parameters
eta = {0.85, ‘1’}; % Rendement de la turbine
rho = {1000, ‘kg/m^3’}; % Densité de l’eau
r = {0.5, ‘m’}; % Rayon moyen de la roue
end
% 🔹 Déclaration des variables internes
variables
T = {0, ‘N*m’}; % Couple généré
Q = {0, ‘m^3/s’}; % Débit volumique
H_head = {0, ‘m’}; % Hauteur d’eau équivalente
end
% 🔹 Bloc des équations
equations
Q == H.q; % Débit entrant dans le port hydraulique
H_head == H.p / (rho * 9.81); % Calcul de la hauteur d’eau équivalente
T == eta * rho * Q * H_head * r; % Formule du couple hydraulique
R.tau == T; % Appliquer le couple sur l’axe mécanique
end
endcomponent
I keep having the same error : Unexepected Matlab expression for the last line (‘endcomponent’). I have already checked a lot of sources of error (hidden spaces, checking that the path is good…). Do you have any idea of what might be wrong ?
Thanks in advance,
Nils Hi everyone, I’m trying to build a custom block with the following code :
component pelton_turbine
% Ce composant calcule le couple généré par l’eau sur la turbine.
% 🔹 Déclaration des ports
nodes
H = foundation.hydraulic.hydraulic; % Port hydraulique
R = foundation.mechanical.rotational.rotational; % Port mécanique rotatif
end
% 🔹 Déclaration des paramètres
parameters
eta = {0.85, ‘1’}; % Rendement de la turbine
rho = {1000, ‘kg/m^3’}; % Densité de l’eau
r = {0.5, ‘m’}; % Rayon moyen de la roue
end
% 🔹 Déclaration des variables internes
variables
T = {0, ‘N*m’}; % Couple généré
Q = {0, ‘m^3/s’}; % Débit volumique
H_head = {0, ‘m’}; % Hauteur d’eau équivalente
end
% 🔹 Bloc des équations
equations
Q == H.q; % Débit entrant dans le port hydraulique
H_head == H.p / (rho * 9.81); % Calcul de la hauteur d’eau équivalente
T == eta * rho * Q * H_head * r; % Formule du couple hydraulique
R.tau == T; % Appliquer le couple sur l’axe mécanique
end
endcomponent
I keep having the same error : Unexepected Matlab expression for the last line (‘endcomponent’). I have already checked a lot of sources of error (hidden spaces, checking that the path is good…). Do you have any idea of what might be wrong ?
Thanks in advance,
Nils simscape, custom block, error MATLAB Answers — New Questions
Implementing MRAC for Robotic arm of unknown link lengths
Hi! I am currently trying to implement MRAC in Simulink for a 3DOF robotic arm, but I’m a bit confused on the block connections and deriving the reference model.
For the reference model im using a 2nd order equation because the system in non linear, but if link length is unknown how do I implement the adaptive control because to use transfer functions the values should be known? The reference model im trying to implement is : b /s^2 +2s + b
This is my model with PID, but if I want to replace PID with MARC where should I connect the block?Hi! I am currently trying to implement MRAC in Simulink for a 3DOF robotic arm, but I’m a bit confused on the block connections and deriving the reference model.
For the reference model im using a 2nd order equation because the system in non linear, but if link length is unknown how do I implement the adaptive control because to use transfer functions the values should be known? The reference model im trying to implement is : b /s^2 +2s + b
This is my model with PID, but if I want to replace PID with MARC where should I connect the block? Hi! I am currently trying to implement MRAC in Simulink for a 3DOF robotic arm, but I’m a bit confused on the block connections and deriving the reference model.
For the reference model im using a 2nd order equation because the system in non linear, but if link length is unknown how do I implement the adaptive control because to use transfer functions the values should be known? The reference model im trying to implement is : b /s^2 +2s + b
This is my model with PID, but if I want to replace PID with MARC where should I connect the block? marc, matlab, simulink, control, robotics, adaptive control MATLAB Answers — New Questions
Shapley Values for svm classification with 10 Kfold
Hi,
I would like to compute Shapley Values with SVM tested with Kfold= 10. Here my code:
load fisheriris
inds = ~strcmp(species,’setosa’);
X = meas(inds,3:4);
y = species(inds);
SVMModel = fitcsvm(X,y,Kfold=10);
explainer = shapley(SVMModel);
How I can solve this?Hi,
I would like to compute Shapley Values with SVM tested with Kfold= 10. Here my code:
load fisheriris
inds = ~strcmp(species,’setosa’);
X = meas(inds,3:4);
y = species(inds);
SVMModel = fitcsvm(X,y,Kfold=10);
explainer = shapley(SVMModel);
How I can solve this? Hi,
I would like to compute Shapley Values with SVM tested with Kfold= 10. Here my code:
load fisheriris
inds = ~strcmp(species,’setosa’);
X = meas(inds,3:4);
y = species(inds);
SVMModel = fitcsvm(X,y,Kfold=10);
explainer = shapley(SVMModel);
How I can solve this? shapley, svm, kfold MATLAB Answers — New Questions
Design of smart meters to curb electricity issues
Working on designing a smart meter to curb electricity connections and power issuesWorking on designing a smart meter to curb electricity connections and power issues Working on designing a smart meter to curb electricity connections and power issues electric_motor_control MATLAB Answers — New Questions
create a program that determines the largest three numbers assigned to variables a,b and c and display the largest number matlab
create a program that determines the largest three numbers assigned to variables A,B and C and display the largest number matlabcreate a program that determines the largest three numbers assigned to variables A,B and C and display the largest number matlab create a program that determines the largest three numbers assigned to variables A,B and C and display the largest number matlab homework MATLAB Answers — New Questions
Conditional RTE Write of structure in AUTOSAR Generated Code
I would like to generate code with the "Rte_Write" call inside an "if" statement. , but output should be strcuture datatype. Problem is Autosar generator will not allow me to use virtual port in this case and RTE Write is always located on end of main runnable, not in if statement.
Error:When model ‘COMH_Mini’ has function-call root-level Inport blocks, or is set up to export functions, the input signal to the root-level Outport block ‘COMH_Mini/COMH_sigGroup_CAN_H2CU_33_CINV100msNo01_COMH_sigGroup_CAN_H2CU_33_CINV100msNo01’ cannot be a virtual bus. Consider replacing this Outport block with an Out Bus Element block, or making the input signal a nonvirtual bus.I would like to generate code with the "Rte_Write" call inside an "if" statement. , but output should be strcuture datatype. Problem is Autosar generator will not allow me to use virtual port in this case and RTE Write is always located on end of main runnable, not in if statement.
Error:When model ‘COMH_Mini’ has function-call root-level Inport blocks, or is set up to export functions, the input signal to the root-level Outport block ‘COMH_Mini/COMH_sigGroup_CAN_H2CU_33_CINV100msNo01_COMH_sigGroup_CAN_H2CU_33_CINV100msNo01’ cannot be a virtual bus. Consider replacing this Outport block with an Out Bus Element block, or making the input signal a nonvirtual bus. I would like to generate code with the "Rte_Write" call inside an "if" statement. , but output should be strcuture datatype. Problem is Autosar generator will not allow me to use virtual port in this case and RTE Write is always located on end of main runnable, not in if statement.
Error:When model ‘COMH_Mini’ has function-call root-level Inport blocks, or is set up to export functions, the input signal to the root-level Outport block ‘COMH_Mini/COMH_sigGroup_CAN_H2CU_33_CINV100msNo01_COMH_sigGroup_CAN_H2CU_33_CINV100msNo01’ cannot be a virtual bus. Consider replacing this Outport block with an Out Bus Element block, or making the input signal a nonvirtual bus. autosar, rte write, structures MATLAB Answers — New Questions
To pass a variable outside a parfor loop
I have a loop that looks like:
parfor j=1:length(P)
for i=1:(length(A)-1)
%unnecessary calculations
for i=1:(length(A)-1)
end
for k=1:(length(B)-1)
ri(k,l)=len(k); %len is a vector, that has been defined already
sr(1,i)=r(i); %r is a vector, that has been defined already
end
%unnecessary calculations
end
%unnecessary calculations
end
plot(ri,sr); %I know that these two vectors have different dimensions, it’s just example to show, that I use variables outside parfor
%loop. By the way, I use the variables in functions "plot" and "meshgrid"
So I tried to use cell arrays as Walter Roberson recommend:
%in my program (length(A)-1)=40, (length(B)-1) = 10;
ri=cell(10,40); sr=cell(1,40);
parfor j=1:length(P)
for i=1:(length(A)-1)
for k=1:(length(B)-1)
ri{k,l}=len(k);
sr{1,i}=r(i);
end
end
end
ri1=cell2mat(ri);
sr1=cell2mat(sr); %last two lines are my own ideas I don’t know good or bad
plot(ri1,sr1);
And matlab writes that because of the way of using variables the parfor loop can’t be executed. It writes the same as before changing the code.
The main error is "Unable to classify the variable ‘ri’ in the body of the parfor-loop". Can you help me, please?I have a loop that looks like:
parfor j=1:length(P)
for i=1:(length(A)-1)
%unnecessary calculations
for i=1:(length(A)-1)
end
for k=1:(length(B)-1)
ri(k,l)=len(k); %len is a vector, that has been defined already
sr(1,i)=r(i); %r is a vector, that has been defined already
end
%unnecessary calculations
end
%unnecessary calculations
end
plot(ri,sr); %I know that these two vectors have different dimensions, it’s just example to show, that I use variables outside parfor
%loop. By the way, I use the variables in functions "plot" and "meshgrid"
So I tried to use cell arrays as Walter Roberson recommend:
%in my program (length(A)-1)=40, (length(B)-1) = 10;
ri=cell(10,40); sr=cell(1,40);
parfor j=1:length(P)
for i=1:(length(A)-1)
for k=1:(length(B)-1)
ri{k,l}=len(k);
sr{1,i}=r(i);
end
end
end
ri1=cell2mat(ri);
sr1=cell2mat(sr); %last two lines are my own ideas I don’t know good or bad
plot(ri1,sr1);
And matlab writes that because of the way of using variables the parfor loop can’t be executed. It writes the same as before changing the code.
The main error is "Unable to classify the variable ‘ri’ in the body of the parfor-loop". Can you help me, please? I have a loop that looks like:
parfor j=1:length(P)
for i=1:(length(A)-1)
%unnecessary calculations
for i=1:(length(A)-1)
end
for k=1:(length(B)-1)
ri(k,l)=len(k); %len is a vector, that has been defined already
sr(1,i)=r(i); %r is a vector, that has been defined already
end
%unnecessary calculations
end
%unnecessary calculations
end
plot(ri,sr); %I know that these two vectors have different dimensions, it’s just example to show, that I use variables outside parfor
%loop. By the way, I use the variables in functions "plot" and "meshgrid"
So I tried to use cell arrays as Walter Roberson recommend:
%in my program (length(A)-1)=40, (length(B)-1) = 10;
ri=cell(10,40); sr=cell(1,40);
parfor j=1:length(P)
for i=1:(length(A)-1)
for k=1:(length(B)-1)
ri{k,l}=len(k);
sr{1,i}=r(i);
end
end
end
ri1=cell2mat(ri);
sr1=cell2mat(sr); %last two lines are my own ideas I don’t know good or bad
plot(ri1,sr1);
And matlab writes that because of the way of using variables the parfor loop can’t be executed. It writes the same as before changing the code.
The main error is "Unable to classify the variable ‘ri’ in the body of the parfor-loop". Can you help me, please? parfor, parallel computing MATLAB Answers — New Questions
Plotting a 3d network model using graph
I want to plot a 3 dimensional network model using the graph function.
for example
edges1 = [1,1,1,2,2,2,2,2,2,2,3,3,3,3,3,3,4,4,4,4,4,5,6,6,6,6,6,7,8,8,8,8,10,11,11,11];
egdes2 = [2,3,4,3,4,5,6,7,8,9,4,5,6,10,11,12,7,8,10,11,13,6,8,9,11,12,14,8,9,11,13,14,11,12,13,14];
x = [0,0,0.5000,0.5000,0,0.5000,0,0.5000,0,1.0000,1.0000,1.0000,1.0000,1.0000];
y = [0,0.5000,0,0.5000,0,0.5000,1.0000,1.0000,1.0000,0,0.5000,0,1.0000,1.0000];
z = [0,0.5000,0.5000,0,1.0000,1.0000,0,0.5000,1.0000,0,0.5000,1.0000,0,1.0000];
G = graph(edges1,egdes2);
plot(G,’Xdata’,x,’Ydata’,y,’Zdata’,z)
However, the line visualization does not give good depth percepsion, and 3d structure can only be percieved when roatating the image.
I’m looking for a way to give the edges some volume to improve visualization, without making the image too heavy to handle.
Is there a neat way to do this?
Thanks!I want to plot a 3 dimensional network model using the graph function.
for example
edges1 = [1,1,1,2,2,2,2,2,2,2,3,3,3,3,3,3,4,4,4,4,4,5,6,6,6,6,6,7,8,8,8,8,10,11,11,11];
egdes2 = [2,3,4,3,4,5,6,7,8,9,4,5,6,10,11,12,7,8,10,11,13,6,8,9,11,12,14,8,9,11,13,14,11,12,13,14];
x = [0,0,0.5000,0.5000,0,0.5000,0,0.5000,0,1.0000,1.0000,1.0000,1.0000,1.0000];
y = [0,0.5000,0,0.5000,0,0.5000,1.0000,1.0000,1.0000,0,0.5000,0,1.0000,1.0000];
z = [0,0.5000,0.5000,0,1.0000,1.0000,0,0.5000,1.0000,0,0.5000,1.0000,0,1.0000];
G = graph(edges1,egdes2);
plot(G,’Xdata’,x,’Ydata’,y,’Zdata’,z)
However, the line visualization does not give good depth percepsion, and 3d structure can only be percieved when roatating the image.
I’m looking for a way to give the edges some volume to improve visualization, without making the image too heavy to handle.
Is there a neat way to do this?
Thanks! I want to plot a 3 dimensional network model using the graph function.
for example
edges1 = [1,1,1,2,2,2,2,2,2,2,3,3,3,3,3,3,4,4,4,4,4,5,6,6,6,6,6,7,8,8,8,8,10,11,11,11];
egdes2 = [2,3,4,3,4,5,6,7,8,9,4,5,6,10,11,12,7,8,10,11,13,6,8,9,11,12,14,8,9,11,13,14,11,12,13,14];
x = [0,0,0.5000,0.5000,0,0.5000,0,0.5000,0,1.0000,1.0000,1.0000,1.0000,1.0000];
y = [0,0.5000,0,0.5000,0,0.5000,1.0000,1.0000,1.0000,0,0.5000,0,1.0000,1.0000];
z = [0,0.5000,0.5000,0,1.0000,1.0000,0,0.5000,1.0000,0,0.5000,1.0000,0,1.0000];
G = graph(edges1,egdes2);
plot(G,’Xdata’,x,’Ydata’,y,’Zdata’,z)
However, the line visualization does not give good depth percepsion, and 3d structure can only be percieved when roatating the image.
I’m looking for a way to give the edges some volume to improve visualization, without making the image too heavy to handle.
Is there a neat way to do this?
Thanks! graph, 3d plots MATLAB Answers — New Questions
How can I control a revolute joint with a stepper motor ?
Hello, I want to control a stage which is actuated by a lead screw and stepper motor. Ideally, I need to specify the velocity of the stage or angular velocity of the rotational joint 1 so that it rotates the screw. I used simscape to generate the block diagram from my CAD model from onshape (link below). Is there any way of doing this ? I have tried using the stepper motor model from the simelectronics library but had trouble connecting it to the joint.
Simscape model:
https://drive.google.com/open?id=1WBuGkkchPfXhgrx0C9gV4moEqcxCi6hq
CAD model:
https://cad.onshape.com/documents/d5ee5d8b466e6650b9cfdac4/w/b05ebd7e69bda94f37ce5c0e/e/71f3ef6f9e38afb071c64dfd
Thank youHello, I want to control a stage which is actuated by a lead screw and stepper motor. Ideally, I need to specify the velocity of the stage or angular velocity of the rotational joint 1 so that it rotates the screw. I used simscape to generate the block diagram from my CAD model from onshape (link below). Is there any way of doing this ? I have tried using the stepper motor model from the simelectronics library but had trouble connecting it to the joint.
Simscape model:
https://drive.google.com/open?id=1WBuGkkchPfXhgrx0C9gV4moEqcxCi6hq
CAD model:
https://cad.onshape.com/documents/d5ee5d8b466e6650b9cfdac4/w/b05ebd7e69bda94f37ce5c0e/e/71f3ef6f9e38afb071c64dfd
Thank you Hello, I want to control a stage which is actuated by a lead screw and stepper motor. Ideally, I need to specify the velocity of the stage or angular velocity of the rotational joint 1 so that it rotates the screw. I used simscape to generate the block diagram from my CAD model from onshape (link below). Is there any way of doing this ? I have tried using the stepper motor model from the simelectronics library but had trouble connecting it to the joint.
Simscape model:
https://drive.google.com/open?id=1WBuGkkchPfXhgrx0C9gV4moEqcxCi6hq
CAD model:
https://cad.onshape.com/documents/d5ee5d8b466e6650b9cfdac4/w/b05ebd7e69bda94f37ce5c0e/e/71f3ef6f9e38afb071c64dfd
Thank you simscape, stepper, motor, simelectronics, revolute, joint, power_electronics_control, electric_motor_control MATLAB Answers — New Questions
How to plan path in Cartesian coordinate for robotic manipulator
I uploaded a 6Dof robotic arm rigid tree to matlab simulink , now i need to move the end effector in the shape ‘ M ‘ . How do i obtain the waypoints of the shape ‘ M ‘I uploaded a 6Dof robotic arm rigid tree to matlab simulink , now i need to move the end effector in the shape ‘ M ‘ . How do i obtain the waypoints of the shape ‘ M ‘ I uploaded a 6Dof robotic arm rigid tree to matlab simulink , now i need to move the end effector in the shape ‘ M ‘ . How do i obtain the waypoints of the shape ‘ M ‘ pathplanning, waypoints MATLAB Answers — New Questions
Convert triangular matlab mesh into .msh file
I have generated a 2D triangular mesh in matlab, however, I need to find a way to convert it into a .msh file. I have been searching for ages but haven’t found any way to do this. I think the easiest way to convert it into a .msh file would be in GMSH but I can’t find a way to upload the mesh into GMSH. I’m open to any alternatives.
Many thanks.I have generated a 2D triangular mesh in matlab, however, I need to find a way to convert it into a .msh file. I have been searching for ages but haven’t found any way to do this. I think the easiest way to convert it into a .msh file would be in GMSH but I can’t find a way to upload the mesh into GMSH. I’m open to any alternatives.
Many thanks. I have generated a 2D triangular mesh in matlab, however, I need to find a way to convert it into a .msh file. I have been searching for ages but haven’t found any way to do this. I think the easiest way to convert it into a .msh file would be in GMSH but I can’t find a way to upload the mesh into GMSH. I’m open to any alternatives.
Many thanks. mesh, model, export, file MATLAB Answers — New Questions
Can the standard Soft Actor Critic (SAC) algorithm in Matlab be adapted for hybrid action spaces, or is there another reinforcement learning algorithm in Matlab that is better
The current implementation of the Soft Actor Critic (SAC) algorithm in Matlab is designed only for problems with continuous or discrete action spaces. I’m facing a problem that requires dealing with hybrid action spaces, where some actions are continuous and others are discrete. I am aware that implementations of SAC that accommodate hybrid action spaces have been suggested in the literature. Is it feasible to modify the standard Matlab implementations to handle hybrid actions? If not, is there another reinforcement learning algorithm available in Matlab that is suitable for addressing hybrid action spaces?The current implementation of the Soft Actor Critic (SAC) algorithm in Matlab is designed only for problems with continuous or discrete action spaces. I’m facing a problem that requires dealing with hybrid action spaces, where some actions are continuous and others are discrete. I am aware that implementations of SAC that accommodate hybrid action spaces have been suggested in the literature. Is it feasible to modify the standard Matlab implementations to handle hybrid actions? If not, is there another reinforcement learning algorithm available in Matlab that is suitable for addressing hybrid action spaces? The current implementation of the Soft Actor Critic (SAC) algorithm in Matlab is designed only for problems with continuous or discrete action spaces. I’m facing a problem that requires dealing with hybrid action spaces, where some actions are continuous and others are discrete. I am aware that implementations of SAC that accommodate hybrid action spaces have been suggested in the literature. Is it feasible to modify the standard Matlab implementations to handle hybrid actions? If not, is there another reinforcement learning algorithm available in Matlab that is suitable for addressing hybrid action spaces? hybird reinforcement learning MATLAB Answers — New Questions
Issue with serial communication blocks from support package for arduino nano(CH340 clone)
I’m using arduino nano(ch340) and implementing serial communication with the Raspberry Pi 4B. I’m using USB cable rather than onboard uart pins. I’ve been trying to send data through serial transmit block (from nano) but no results at all. You cannot use ‘monitor and tune’ so only been reading the data(in both Arduino ide’s serial monitor and rasp pi’s terminal) after uploading the model.
The output in serial monitor is gibberish (boxes) while in terminal(screen) it is not visible at all. I generated a model for rasp pi with serial read block from support package where data is zero and status port indicates ‘data not available’. Tried all three modes for transmit block: write, print, println, but same results. I programmed a test program in arduino ide with serial.println function which was successfully displayed results in both terminal and display from rasp pi simulink model. I’ve successfully implemented basic test models like ‘led blink’ in simulink for arduino so my inference is that the problem is only with serial transmit block and its generated code.
My aim is to establish bidirectional serial communication between Raspberry pi and arduino nano, to exchange multiple values simultaneously(probably having different data types) in an array and separate them for their intended use.I’m using arduino nano(ch340) and implementing serial communication with the Raspberry Pi 4B. I’m using USB cable rather than onboard uart pins. I’ve been trying to send data through serial transmit block (from nano) but no results at all. You cannot use ‘monitor and tune’ so only been reading the data(in both Arduino ide’s serial monitor and rasp pi’s terminal) after uploading the model.
The output in serial monitor is gibberish (boxes) while in terminal(screen) it is not visible at all. I generated a model for rasp pi with serial read block from support package where data is zero and status port indicates ‘data not available’. Tried all three modes for transmit block: write, print, println, but same results. I programmed a test program in arduino ide with serial.println function which was successfully displayed results in both terminal and display from rasp pi simulink model. I’ve successfully implemented basic test models like ‘led blink’ in simulink for arduino so my inference is that the problem is only with serial transmit block and its generated code.
My aim is to establish bidirectional serial communication between Raspberry pi and arduino nano, to exchange multiple values simultaneously(probably having different data types) in an array and separate them for their intended use. I’m using arduino nano(ch340) and implementing serial communication with the Raspberry Pi 4B. I’m using USB cable rather than onboard uart pins. I’ve been trying to send data through serial transmit block (from nano) but no results at all. You cannot use ‘monitor and tune’ so only been reading the data(in both Arduino ide’s serial monitor and rasp pi’s terminal) after uploading the model.
The output in serial monitor is gibberish (boxes) while in terminal(screen) it is not visible at all. I generated a model for rasp pi with serial read block from support package where data is zero and status port indicates ‘data not available’. Tried all three modes for transmit block: write, print, println, but same results. I programmed a test program in arduino ide with serial.println function which was successfully displayed results in both terminal and display from rasp pi simulink model. I’ve successfully implemented basic test models like ‘led blink’ in simulink for arduino so my inference is that the problem is only with serial transmit block and its generated code.
My aim is to establish bidirectional serial communication between Raspberry pi and arduino nano, to exchange multiple values simultaneously(probably having different data types) in an array and separate them for their intended use. serial communication, arduino and raspberry pi MATLAB Answers — New Questions