Category: Matlab
Category Archives: Matlab
How to translate MATLAB’s euler angle quadrotor equations into body frame?
In the following MIT lecture notes Equation (6.10) is given with body-frame angular velocities, whereas in this Matlab tutorial, the equations are given in euler angles. I have tried, using cross product properties, to translate between the two. The two equation presentations are given in detail in this post, I was unable to move the latex expressions over to Matlab’s latex editor.In the following MIT lecture notes Equation (6.10) is given with body-frame angular velocities, whereas in this Matlab tutorial, the equations are given in euler angles. I have tried, using cross product properties, to translate between the two. The two equation presentations are given in detail in this post, I was unable to move the latex expressions over to Matlab’s latex editor. In the following MIT lecture notes Equation (6.10) is given with body-frame angular velocities, whereas in this Matlab tutorial, the equations are given in euler angles. I have tried, using cross product properties, to translate between the two. The two equation presentations are given in detail in this post, I was unable to move the latex expressions over to Matlab’s latex editor. control, mathematics, equation, matrix manipulation MATLAB Answers — New Questions
How to create a transparent, rectangular patch with rounded corners?
It would be helpful to create a transparent, rectangular patch with rounded corners. This could be acheived with something like this:
h = rectangle(‘Position’, [x1, y1, x2, y2], …
‘Curvature’, 0.2, …
‘FaceColor’, ‘r’, …
‘EdgeColor’, ‘r’);
Unfortunately, rectangle properties do not include FaceAlpha and EdgeAlpha. Patch objects do, so I thought that I could get the XData and YData properties of the rectangle object from which to create a patch object. No dice; wasn’t able to find these properties.
Again, the desired features are: transparency + rounded corners + face colorIt would be helpful to create a transparent, rectangular patch with rounded corners. This could be acheived with something like this:
h = rectangle(‘Position’, [x1, y1, x2, y2], …
‘Curvature’, 0.2, …
‘FaceColor’, ‘r’, …
‘EdgeColor’, ‘r’);
Unfortunately, rectangle properties do not include FaceAlpha and EdgeAlpha. Patch objects do, so I thought that I could get the XData and YData properties of the rectangle object from which to create a patch object. No dice; wasn’t able to find these properties.
Again, the desired features are: transparency + rounded corners + face color It would be helpful to create a transparent, rectangular patch with rounded corners. This could be acheived with something like this:
h = rectangle(‘Position’, [x1, y1, x2, y2], …
‘Curvature’, 0.2, …
‘FaceColor’, ‘r’, …
‘EdgeColor’, ‘r’);
Unfortunately, rectangle properties do not include FaceAlpha and EdgeAlpha. Patch objects do, so I thought that I could get the XData and YData properties of the rectangle object from which to create a patch object. No dice; wasn’t able to find these properties.
Again, the desired features are: transparency + rounded corners + face color rectangle, patch MATLAB Answers — New Questions
In MATLAB ..Am doing research in melanoma skin cancer detection..In ABCD rule: how to find color value??
for C-Color i need to find the presence of white, red, lightbrown, darkbrown, blue-gray, black colors in my lesion image..A score of one is assigned on presence of each colour in the image..have to return the count of color that is range from 0 to 6.how to do that??for C-Color i need to find the presence of white, red, lightbrown, darkbrown, blue-gray, black colors in my lesion image..A score of one is assigned on presence of each colour in the image..have to return the count of color that is range from 0 to 6.how to do that?? for C-Color i need to find the presence of white, red, lightbrown, darkbrown, blue-gray, black colors in my lesion image..A score of one is assigned on presence of each colour in the image..have to return the count of color that is range from 0 to 6.how to do that?? abcd rule – color, skin cancer, melanoma, cancer MATLAB Answers — New Questions
‘Text’ must be character vector issue in app designer
Hi, I’m quite new to MATLAB so please bear with me. I’m assigning the values produced by MATRIX_VALUES from a seperate script to the button names seen below, but I keep getting an ‘Text’ must be a character vector error on the btn.Text = C{i} line. MATRIX_VALUES(); is a 4×4, and I shaped it to a 1×16 vector, which should fit the loop conditions fine, but I keep getting this error. Any help would be massively appreicated, thanks.
MATRIX_VALUES();
x = reshape(FINAL_Shuffled_Columns,1,[]);
C = {x}; %Making a cell with the matrix of values from MATRIX_VALUES
mybuttons = {app.Button1,app.Button2,app.Button3,app.Button4,…
app.Button5,app.Button6,app.Button7,app.Button8,…
app.Button9,app.Button10,app.Button11,app.Button12,…
app.Button13,app.Button14,app.Button15,app.Button16};
for i = 1:16
btn = mybuttons{i};
btn.Text = C{i};
endHi, I’m quite new to MATLAB so please bear with me. I’m assigning the values produced by MATRIX_VALUES from a seperate script to the button names seen below, but I keep getting an ‘Text’ must be a character vector error on the btn.Text = C{i} line. MATRIX_VALUES(); is a 4×4, and I shaped it to a 1×16 vector, which should fit the loop conditions fine, but I keep getting this error. Any help would be massively appreicated, thanks.
MATRIX_VALUES();
x = reshape(FINAL_Shuffled_Columns,1,[]);
C = {x}; %Making a cell with the matrix of values from MATRIX_VALUES
mybuttons = {app.Button1,app.Button2,app.Button3,app.Button4,…
app.Button5,app.Button6,app.Button7,app.Button8,…
app.Button9,app.Button10,app.Button11,app.Button12,…
app.Button13,app.Button14,app.Button15,app.Button16};
for i = 1:16
btn = mybuttons{i};
btn.Text = C{i};
end Hi, I’m quite new to MATLAB so please bear with me. I’m assigning the values produced by MATRIX_VALUES from a seperate script to the button names seen below, but I keep getting an ‘Text’ must be a character vector error on the btn.Text = C{i} line. MATRIX_VALUES(); is a 4×4, and I shaped it to a 1×16 vector, which should fit the loop conditions fine, but I keep getting this error. Any help would be massively appreicated, thanks.
MATRIX_VALUES();
x = reshape(FINAL_Shuffled_Columns,1,[]);
C = {x}; %Making a cell with the matrix of values from MATRIX_VALUES
mybuttons = {app.Button1,app.Button2,app.Button3,app.Button4,…
app.Button5,app.Button6,app.Button7,app.Button8,…
app.Button9,app.Button10,app.Button11,app.Button12,…
app.Button13,app.Button14,app.Button15,app.Button16};
for i = 1:16
btn = mybuttons{i};
btn.Text = C{i};
end appdesigner, button MATLAB Answers — New Questions
How to change distance between groups of bars in a bar plot?
I have 3 sets of data that I am plotting using ‘bar’. This generates sets of grouped bars. I know one can change the width of bars such that within a group they have some gap between them.
But how do I change the distance between groups of bars? I could not find any solution online, except calculating the x coordinates by yourself and plotting each dataset separately. If that’s the only way, Mathworks should do something about it!I have 3 sets of data that I am plotting using ‘bar’. This generates sets of grouped bars. I know one can change the width of bars such that within a group they have some gap between them.
But how do I change the distance between groups of bars? I could not find any solution online, except calculating the x coordinates by yourself and plotting each dataset separately. If that’s the only way, Mathworks should do something about it! I have 3 sets of data that I am plotting using ‘bar’. This generates sets of grouped bars. I know one can change the width of bars such that within a group they have some gap between them.
But how do I change the distance between groups of bars? I could not find any solution online, except calculating the x coordinates by yourself and plotting each dataset separately. If that’s the only way, Mathworks should do something about it! barplot, group, bar, width, distance MATLAB Answers — New Questions
Is it possible to make ‘uisetcolor’ integrated in GUI?
Hi
I’m trying to build ‘uisetcolor’ into my GUI.
At the moment, if I run my GUI, the ‘uisetcolor’ pops up in a seperate window. See below.
What do I need to do in order to make it shown in my GUI interface rather than a stand-alone window?
If you noticed that my uisetcolor interface looks different to the one you know that is because i’m using matlab 2018a so uisetcolor is missing the gradient color picker which is only available in the later matlab version such as 2018b.
Please help.Hi
I’m trying to build ‘uisetcolor’ into my GUI.
At the moment, if I run my GUI, the ‘uisetcolor’ pops up in a seperate window. See below.
What do I need to do in order to make it shown in my GUI interface rather than a stand-alone window?
If you noticed that my uisetcolor interface looks different to the one you know that is because i’m using matlab 2018a so uisetcolor is missing the gradient color picker which is only available in the later matlab version such as 2018b.
Please help. Hi
I’m trying to build ‘uisetcolor’ into my GUI.
At the moment, if I run my GUI, the ‘uisetcolor’ pops up in a seperate window. See below.
What do I need to do in order to make it shown in my GUI interface rather than a stand-alone window?
If you noticed that my uisetcolor interface looks different to the one you know that is because i’m using matlab 2018a so uisetcolor is missing the gradient color picker which is only available in the later matlab version such as 2018b.
Please help. uisetcolor, color picker MATLAB Answers — New Questions
Test connection error in the setup process of Arduino support package for Simulink with Arduino Nano 33 BLE board
Hello Everyone,
I’m facing an error with the last step of the setup process in Arduino Support Package for Simulink. In the Test Connection, the Build is done successfully while the Download (ensures the connection between PC and board) fails. I tried solving the issue by following: Post 1 and Post 2 but the issue still persists. The log file outputs:
Sketch uses 924 bytes (3%) of program storage space. Maximum is 30720 bytes.
Global variables use 9 bytes (0%) of dynamic memory, leaving 2039 bytes for local variables. Maximum is 2048 bytes.
�[92mUsed platform�[0m �[92mVersion�[0m �[90mPath�[0m
�[93marduino:avr�[0m 1.8.3 �[90mC:ProgramDataMATLABSupportPackagesR2024aaCLIdatapackagesarduinohardwareavr1.8.3�[0m
Any suggestions?
Thank you!Hello Everyone,
I’m facing an error with the last step of the setup process in Arduino Support Package for Simulink. In the Test Connection, the Build is done successfully while the Download (ensures the connection between PC and board) fails. I tried solving the issue by following: Post 1 and Post 2 but the issue still persists. The log file outputs:
Sketch uses 924 bytes (3%) of program storage space. Maximum is 30720 bytes.
Global variables use 9 bytes (0%) of dynamic memory, leaving 2039 bytes for local variables. Maximum is 2048 bytes.
�[92mUsed platform�[0m �[92mVersion�[0m �[90mPath�[0m
�[93marduino:avr�[0m 1.8.3 �[90mC:ProgramDataMATLABSupportPackagesR2024aaCLIdatapackagesarduinohardwareavr1.8.3�[0m
Any suggestions?
Thank you! Hello Everyone,
I’m facing an error with the last step of the setup process in Arduino Support Package for Simulink. In the Test Connection, the Build is done successfully while the Download (ensures the connection between PC and board) fails. I tried solving the issue by following: Post 1 and Post 2 but the issue still persists. The log file outputs:
Sketch uses 924 bytes (3%) of program storage space. Maximum is 30720 bytes.
Global variables use 9 bytes (0%) of dynamic memory, leaving 2039 bytes for local variables. Maximum is 2048 bytes.
�[92mUsed platform�[0m �[92mVersion�[0m �[90mPath�[0m
�[93marduino:avr�[0m 1.8.3 �[90mC:ProgramDataMATLABSupportPackagesR2024aaCLIdatapackagesarduinohardwareavr1.8.3�[0m
Any suggestions?
Thank you! arduino, simulink MATLAB Answers — New Questions
pie chart creation with name (number) and corresponding percentage
Hi! I would like to create a pie chart like in the present demo:
x = [1,2,3];
p = pie(x);
pText = findobj(p,’Type’,’text’);
percentValues = get(pText,’String’);
txt = {‘Item A: ‘;’Item B: ‘;’Item C: ‘};
combinedtxt = strcat(txt,percentValues);
pText(1).String = combinedtxt(1);
pText(2).String = combinedtxt(2);
pText(3).String = combinedtxt(3);
How can I achieve the same result with my data?
I tried it this way:
number = [78;79;80;81;82;83;84;85;86;87;88]’;
value = [4509;5239;6400;9074;11047;13147;15137;13909;6354;1152;183]’;
number2 = {};
for K = 1:height(number)
number1 = sprintf(‘%.0f’,number(K));
number2 = [number2,{number1}];
end
number2 = number2.’;
p = pie(value);
pText = findobj(p,’Type’,’text’);
percentValues = get(pText,’String’);
combinedtxt = strcat(number2,percentValues);
for K = 1:height(value)
pText(K).String = combinedtxt(K);
endHi! I would like to create a pie chart like in the present demo:
x = [1,2,3];
p = pie(x);
pText = findobj(p,’Type’,’text’);
percentValues = get(pText,’String’);
txt = {‘Item A: ‘;’Item B: ‘;’Item C: ‘};
combinedtxt = strcat(txt,percentValues);
pText(1).String = combinedtxt(1);
pText(2).String = combinedtxt(2);
pText(3).String = combinedtxt(3);
How can I achieve the same result with my data?
I tried it this way:
number = [78;79;80;81;82;83;84;85;86;87;88]’;
value = [4509;5239;6400;9074;11047;13147;15137;13909;6354;1152;183]’;
number2 = {};
for K = 1:height(number)
number1 = sprintf(‘%.0f’,number(K));
number2 = [number2,{number1}];
end
number2 = number2.’;
p = pie(value);
pText = findobj(p,’Type’,’text’);
percentValues = get(pText,’String’);
combinedtxt = strcat(number2,percentValues);
for K = 1:height(value)
pText(K).String = combinedtxt(K);
end Hi! I would like to create a pie chart like in the present demo:
x = [1,2,3];
p = pie(x);
pText = findobj(p,’Type’,’text’);
percentValues = get(pText,’String’);
txt = {‘Item A: ‘;’Item B: ‘;’Item C: ‘};
combinedtxt = strcat(txt,percentValues);
pText(1).String = combinedtxt(1);
pText(2).String = combinedtxt(2);
pText(3).String = combinedtxt(3);
How can I achieve the same result with my data?
I tried it this way:
number = [78;79;80;81;82;83;84;85;86;87;88]’;
value = [4509;5239;6400;9074;11047;13147;15137;13909;6354;1152;183]’;
number2 = {};
for K = 1:height(number)
number1 = sprintf(‘%.0f’,number(K));
number2 = [number2,{number1}];
end
number2 = number2.’;
p = pie(value);
pText = findobj(p,’Type’,’text’);
percentValues = get(pText,’String’);
combinedtxt = strcat(number2,percentValues);
for K = 1:height(value)
pText(K).String = combinedtxt(K);
end pie, chart MATLAB Answers — New Questions
Need input on 508 compliant colors in MATLAB
Hi
I am putting together a training class to inform fellows/staff where to find the 508 compliant accessible color schemes in
various programs. I would like to include MATLAB in the class.
I don’t use the program myself, so can you point me to a set or multiple sets of colors that are 508 compliant?
Thank you,
Deb CroteauHi
I am putting together a training class to inform fellows/staff where to find the 508 compliant accessible color schemes in
various programs. I would like to include MATLAB in the class.
I don’t use the program myself, so can you point me to a set or multiple sets of colors that are 508 compliant?
Thank you,
Deb Croteau Hi
I am putting together a training class to inform fellows/staff where to find the 508 compliant accessible color schemes in
various programs. I would like to include MATLAB in the class.
I don’t use the program myself, so can you point me to a set or multiple sets of colors that are 508 compliant?
Thank you,
Deb Croteau 508 color compliant schemes MATLAB Answers — New Questions
State Flow C Action Language Bitwise Operators
I am trying to use bitwise operators to AND as well as OR an uint value with an int value in stateflow with C action language. I need to use 32 bit values but the results appear to be incorrect with 32 bit values, while 8-, 16-, and 64- bit values all seem to give correct results. Image below shows the stateflow chart and correct results using 16 bit values vs incorrect results with 32 bit values. Am I missing something? Or is this a known issue?I am trying to use bitwise operators to AND as well as OR an uint value with an int value in stateflow with C action language. I need to use 32 bit values but the results appear to be incorrect with 32 bit values, while 8-, 16-, and 64- bit values all seem to give correct results. Image below shows the stateflow chart and correct results using 16 bit values vs incorrect results with 32 bit values. Am I missing something? Or is this a known issue? I am trying to use bitwise operators to AND as well as OR an uint value with an int value in stateflow with C action language. I need to use 32 bit values but the results appear to be incorrect with 32 bit values, while 8-, 16-, and 64- bit values all seem to give correct results. Image below shows the stateflow chart and correct results using 16 bit values vs incorrect results with 32 bit values. Am I missing something? Or is this a known issue? bitwise, stateflow, int, uint, and, or MATLAB Answers — New Questions
How do I fix a duplicate name error ?
I am using the simBiology builder app on matlab. I keep receiving an error on one of my models of a duplicate name error ( names are SSRI, SERT, 5-HT ) However, it doesn’t say how to fix it. I have to models in this project and only one has this issue. How do I fix it?I am using the simBiology builder app on matlab. I keep receiving an error on one of my models of a duplicate name error ( names are SSRI, SERT, 5-HT ) However, it doesn’t say how to fix it. I have to models in this project and only one has this issue. How do I fix it? I am using the simBiology builder app on matlab. I keep receiving an error on one of my models of a duplicate name error ( names are SSRI, SERT, 5-HT ) However, it doesn’t say how to fix it. I have to models in this project and only one has this issue. How do I fix it? matlab, simbiology MATLAB Answers — New Questions
Converting a three-column set of data to xyf matrix suitable for a contour plot
I have a set of data (the output of a CFD calculation) that consists of three columns x and y showing location and a third column that we call f which contains the values of the variable calculated for every specific xy location. I want to convert this array to a 2D matrix where x and y are now in the horizontal and vertical directions. Some data points simply do not exist because they are outside of the domain boundaries.
So basically, what I need to do is this (where the black cells are the ones for which the original dataset has no values.):I have a set of data (the output of a CFD calculation) that consists of three columns x and y showing location and a third column that we call f which contains the values of the variable calculated for every specific xy location. I want to convert this array to a 2D matrix where x and y are now in the horizontal and vertical directions. Some data points simply do not exist because they are outside of the domain boundaries.
So basically, what I need to do is this (where the black cells are the ones for which the original dataset has no values.): I have a set of data (the output of a CFD calculation) that consists of three columns x and y showing location and a third column that we call f which contains the values of the variable calculated for every specific xy location. I want to convert this array to a 2D matrix where x and y are now in the horizontal and vertical directions. Some data points simply do not exist because they are outside of the domain boundaries.
So basically, what I need to do is this (where the black cells are the ones for which the original dataset has no values.): resize, columns, matrix, contours plots MATLAB Answers — New Questions
Matlab Report Generator not finding .dotx file after compiling
I’m having some issues using Report Generator to create a .docx from a .dotx template in a compiled web app. It works fine in the app designer but as soon as it is compiled and on the web app server it can no longer find the template file. I have ensured that the Template.dotx file is included in the package while compiling.
The log shows
2024-04-26 14:59:15 Error using mlreportgen.dom.Document/open
2024-04-26 14:59:15 Unable to find template: Template.dotx.
[file,path] = uiputfile(‘*.docx’, ‘Analyzed’, [app.name1 ‘_AN’]);
if isequal(file,0)
disp(‘User selected Cancel’)
else
docxname = fullfile(path,file);
end
makeDOMCompilable();
import mlreportgen.dom.*
import mlreportgen.report.*
D = Document(docxname,’docx’,’Template.dotx’);
open(D);
moveToNextHole(D);
append(D, info);…….
close(D)I’m having some issues using Report Generator to create a .docx from a .dotx template in a compiled web app. It works fine in the app designer but as soon as it is compiled and on the web app server it can no longer find the template file. I have ensured that the Template.dotx file is included in the package while compiling.
The log shows
2024-04-26 14:59:15 Error using mlreportgen.dom.Document/open
2024-04-26 14:59:15 Unable to find template: Template.dotx.
[file,path] = uiputfile(‘*.docx’, ‘Analyzed’, [app.name1 ‘_AN’]);
if isequal(file,0)
disp(‘User selected Cancel’)
else
docxname = fullfile(path,file);
end
makeDOMCompilable();
import mlreportgen.dom.*
import mlreportgen.report.*
D = Document(docxname,’docx’,’Template.dotx’);
open(D);
moveToNextHole(D);
append(D, info);…….
close(D) I’m having some issues using Report Generator to create a .docx from a .dotx template in a compiled web app. It works fine in the app designer but as soon as it is compiled and on the web app server it can no longer find the template file. I have ensured that the Template.dotx file is included in the package while compiling.
The log shows
2024-04-26 14:59:15 Error using mlreportgen.dom.Document/open
2024-04-26 14:59:15 Unable to find template: Template.dotx.
[file,path] = uiputfile(‘*.docx’, ‘Analyzed’, [app.name1 ‘_AN’]);
if isequal(file,0)
disp(‘User selected Cancel’)
else
docxname = fullfile(path,file);
end
makeDOMCompilable();
import mlreportgen.dom.*
import mlreportgen.report.*
D = Document(docxname,’docx’,’Template.dotx’);
open(D);
moveToNextHole(D);
append(D, info);…….
close(D) report generator, compiler, web app, template MATLAB Answers — New Questions
problem onn numerical solution
= 0.3; % Rayon de lissage
dx=0.3;
N =floor(1/dx);
x =0:dx:(pi/sqrt(3)); % Positions des particules
dt = 1/4;
t = 0:dt:1;
M = length(t) – 1;
% Initialisation de la solution approchée et de la matrice A
A = zeros(N, N);
b=zeros(N,1);
uapp=zeros(N,1);
%sol et cond exacte
u_exact = @(x) cos(sqrt(3)*x);
% Construction de la matrice A et du vecteur b
for i = 1:N
for j =N
r_ij = abs(x(i) – x(j));
if r_ij <= h
d2W_dx2 = second_derivative_monaghan_kernel(r_ij, h);
W_value = monaghan_kernel(r_ij, h);
A(i, j) = (u_exact(x(j))- u_exact(x(i))) * d2W_dx2;
b(i) = -3 * u_exact(x(j)) * W_value ;
end
end
end
u_app(1)=1;
u_app(N)=u_exact(pi/sqrt(3));
uapp = bA;
uapp = [0; uapp];
% Affichage des résultats
plot(x , uapp, ‘r’);
hold on;
plot(x, u_exact(x), ‘b–‘);
xlabel(‘x’);
ylabel(‘u’);
legend(‘Solution approchée (SPH)’, ‘Solution exacte’);
title(‘Solution approchée et exacte par SPH’);
grid on;
% Fonctions du noyau de Monaghan
function W_value =monaghan_kernel(r_ij, h)
C= (1/ h);
if r_ij < h
W_value =C*((2 / 3) – (r_ij / h)^2 +(1/2 *(r_ij / h)^3));
elseif r_ij<2*h
W_value =C*((1/6)*(2-(r_ij / h))^3);
else
W_value=0;
end
end
function d2W_dx2 = second_derivative_monaghan_kernel(r_ij, h)
C = (1 / h); % Corrected the denominator
if r_ij < h
d2W_dx2 = -2 * C * (1 – (3 * (r_ij / h)));
elseif r_ij < 2*h
d2W_dx2 = 2 * C * (2 – (r_ij / h)); % Removed extra characters
else
d2W_dx2 = 0;
end
end
I have a problem simulataing a numerical solution for this program
Ineed some help urgent= 0.3; % Rayon de lissage
dx=0.3;
N =floor(1/dx);
x =0:dx:(pi/sqrt(3)); % Positions des particules
dt = 1/4;
t = 0:dt:1;
M = length(t) – 1;
% Initialisation de la solution approchée et de la matrice A
A = zeros(N, N);
b=zeros(N,1);
uapp=zeros(N,1);
%sol et cond exacte
u_exact = @(x) cos(sqrt(3)*x);
% Construction de la matrice A et du vecteur b
for i = 1:N
for j =N
r_ij = abs(x(i) – x(j));
if r_ij <= h
d2W_dx2 = second_derivative_monaghan_kernel(r_ij, h);
W_value = monaghan_kernel(r_ij, h);
A(i, j) = (u_exact(x(j))- u_exact(x(i))) * d2W_dx2;
b(i) = -3 * u_exact(x(j)) * W_value ;
end
end
end
u_app(1)=1;
u_app(N)=u_exact(pi/sqrt(3));
uapp = bA;
uapp = [0; uapp];
% Affichage des résultats
plot(x , uapp, ‘r’);
hold on;
plot(x, u_exact(x), ‘b–‘);
xlabel(‘x’);
ylabel(‘u’);
legend(‘Solution approchée (SPH)’, ‘Solution exacte’);
title(‘Solution approchée et exacte par SPH’);
grid on;
% Fonctions du noyau de Monaghan
function W_value =monaghan_kernel(r_ij, h)
C= (1/ h);
if r_ij < h
W_value =C*((2 / 3) – (r_ij / h)^2 +(1/2 *(r_ij / h)^3));
elseif r_ij<2*h
W_value =C*((1/6)*(2-(r_ij / h))^3);
else
W_value=0;
end
end
function d2W_dx2 = second_derivative_monaghan_kernel(r_ij, h)
C = (1 / h); % Corrected the denominator
if r_ij < h
d2W_dx2 = -2 * C * (1 – (3 * (r_ij / h)));
elseif r_ij < 2*h
d2W_dx2 = 2 * C * (2 – (r_ij / h)); % Removed extra characters
else
d2W_dx2 = 0;
end
end
I have a problem simulataing a numerical solution for this program
Ineed some help urgent = 0.3; % Rayon de lissage
dx=0.3;
N =floor(1/dx);
x =0:dx:(pi/sqrt(3)); % Positions des particules
dt = 1/4;
t = 0:dt:1;
M = length(t) – 1;
% Initialisation de la solution approchée et de la matrice A
A = zeros(N, N);
b=zeros(N,1);
uapp=zeros(N,1);
%sol et cond exacte
u_exact = @(x) cos(sqrt(3)*x);
% Construction de la matrice A et du vecteur b
for i = 1:N
for j =N
r_ij = abs(x(i) – x(j));
if r_ij <= h
d2W_dx2 = second_derivative_monaghan_kernel(r_ij, h);
W_value = monaghan_kernel(r_ij, h);
A(i, j) = (u_exact(x(j))- u_exact(x(i))) * d2W_dx2;
b(i) = -3 * u_exact(x(j)) * W_value ;
end
end
end
u_app(1)=1;
u_app(N)=u_exact(pi/sqrt(3));
uapp = bA;
uapp = [0; uapp];
% Affichage des résultats
plot(x , uapp, ‘r’);
hold on;
plot(x, u_exact(x), ‘b–‘);
xlabel(‘x’);
ylabel(‘u’);
legend(‘Solution approchée (SPH)’, ‘Solution exacte’);
title(‘Solution approchée et exacte par SPH’);
grid on;
% Fonctions du noyau de Monaghan
function W_value =monaghan_kernel(r_ij, h)
C= (1/ h);
if r_ij < h
W_value =C*((2 / 3) – (r_ij / h)^2 +(1/2 *(r_ij / h)^3));
elseif r_ij<2*h
W_value =C*((1/6)*(2-(r_ij / h))^3);
else
W_value=0;
end
end
function d2W_dx2 = second_derivative_monaghan_kernel(r_ij, h)
C = (1 / h); % Corrected the denominator
if r_ij < h
d2W_dx2 = -2 * C * (1 – (3 * (r_ij / h)));
elseif r_ij < 2*h
d2W_dx2 = 2 * C * (2 – (r_ij / h)); % Removed extra characters
else
d2W_dx2 = 0;
end
end
I have a problem simulataing a numerical solution for this program
Ineed some help urgent optimization, numerical integration, differential equations MATLAB Answers — New Questions
The helptool doc.m function is returning an error
I am trying to use the internal doc.m function for finding the help guide to native MATLAB functions. When I call it, instead of pulling up a help page, it returns a series of error messages. I have tried using the which function to make sure that I am trying to call the appropriate function, which confirmed that I do not have any conflicts with other functions that I have written personally. Does anyone know why this might be happening?
>> doc find
Error using split (line 9)
First argument must be text.
Error in matlab.internal.doc.url.DocContentPage/splitPath (line 139)
pathParts = split(pathParts,"/"|"")’;
Error in matlab.internal.doc.url.DocContentPage/buildUrl (line 111)
helpLocation = matlab.internal.doc.url.DocContentPage.splitPath(obj.Product.HelpLocation);
Error in matlab.internal.doc.url.DocPage/getNavigationUrl (line 34)
url = obj.buildUrl;
Error in matlab.internal.doc.ui.DocPageLauncher/openDocPage (line 30)
success = openBrowser(obj.Handler, getNavigationUrl(activePage));
Error in doc (line 79)
launcher.openDocPage;I am trying to use the internal doc.m function for finding the help guide to native MATLAB functions. When I call it, instead of pulling up a help page, it returns a series of error messages. I have tried using the which function to make sure that I am trying to call the appropriate function, which confirmed that I do not have any conflicts with other functions that I have written personally. Does anyone know why this might be happening?
>> doc find
Error using split (line 9)
First argument must be text.
Error in matlab.internal.doc.url.DocContentPage/splitPath (line 139)
pathParts = split(pathParts,"/"|"")’;
Error in matlab.internal.doc.url.DocContentPage/buildUrl (line 111)
helpLocation = matlab.internal.doc.url.DocContentPage.splitPath(obj.Product.HelpLocation);
Error in matlab.internal.doc.url.DocPage/getNavigationUrl (line 34)
url = obj.buildUrl;
Error in matlab.internal.doc.ui.DocPageLauncher/openDocPage (line 30)
success = openBrowser(obj.Handler, getNavigationUrl(activePage));
Error in doc (line 79)
launcher.openDocPage; I am trying to use the internal doc.m function for finding the help guide to native MATLAB functions. When I call it, instead of pulling up a help page, it returns a series of error messages. I have tried using the which function to make sure that I am trying to call the appropriate function, which confirmed that I do not have any conflicts with other functions that I have written personally. Does anyone know why this might be happening?
>> doc find
Error using split (line 9)
First argument must be text.
Error in matlab.internal.doc.url.DocContentPage/splitPath (line 139)
pathParts = split(pathParts,"/"|"")’;
Error in matlab.internal.doc.url.DocContentPage/buildUrl (line 111)
helpLocation = matlab.internal.doc.url.DocContentPage.splitPath(obj.Product.HelpLocation);
Error in matlab.internal.doc.url.DocPage/getNavigationUrl (line 34)
url = obj.buildUrl;
Error in matlab.internal.doc.ui.DocPageLauncher/openDocPage (line 30)
success = openBrowser(obj.Handler, getNavigationUrl(activePage));
Error in doc (line 79)
launcher.openDocPage; doc MATLAB Answers — New Questions
Comparing coefficients and solving equation
Hello everyone,
I would like to find the values of variables comparing coefficients in equation. Let’s have a look at an easy example.
x^2 + 2*x + 5 = (b+4*a)*x^2 + (5*a+b)*x + (-b+2*a)
May someone help me with finding ‘a’ and ‘b’ value?
ThanksHello everyone,
I would like to find the values of variables comparing coefficients in equation. Let’s have a look at an easy example.
x^2 + 2*x + 5 = (b+4*a)*x^2 + (5*a+b)*x + (-b+2*a)
May someone help me with finding ‘a’ and ‘b’ value?
Thanks Hello everyone,
I would like to find the values of variables comparing coefficients in equation. Let’s have a look at an easy example.
x^2 + 2*x + 5 = (b+4*a)*x^2 + (5*a+b)*x + (-b+2*a)
May someone help me with finding ‘a’ and ‘b’ value?
Thanks equation MATLAB Answers — New Questions
Non linear constrain to multi objective integer genetic algorithm
Hello all,
I am trying to set up a multibjective optimization in ga that the possible candidates for the x array have different values (it is an optimal sensor placement problem thus I cannot have the same sensor in the same grid more than once).
When I use the single objcetive function "ga" and define nonlcon = @(x) deal(any(abs(diff(x(1:length(lb)/2))) ~= 1), []) the optimization works fine. (only the first half of the array regards the sensors the rest is the strain component so the values dont have to be unique)
However for the case of "gamultiobj" the non linear constrain does not seem to be taken into account.
Have you ever had such an issue?
ThanksHello all,
I am trying to set up a multibjective optimization in ga that the possible candidates for the x array have different values (it is an optimal sensor placement problem thus I cannot have the same sensor in the same grid more than once).
When I use the single objcetive function "ga" and define nonlcon = @(x) deal(any(abs(diff(x(1:length(lb)/2))) ~= 1), []) the optimization works fine. (only the first half of the array regards the sensors the rest is the strain component so the values dont have to be unique)
However for the case of "gamultiobj" the non linear constrain does not seem to be taken into account.
Have you ever had such an issue?
Thanks Hello all,
I am trying to set up a multibjective optimization in ga that the possible candidates for the x array have different values (it is an optimal sensor placement problem thus I cannot have the same sensor in the same grid more than once).
When I use the single objcetive function "ga" and define nonlcon = @(x) deal(any(abs(diff(x(1:length(lb)/2))) ~= 1), []) the optimization works fine. (only the first half of the array regards the sensors the rest is the strain component so the values dont have to be unique)
However for the case of "gamultiobj" the non linear constrain does not seem to be taken into account.
Have you ever had such an issue?
Thanks gamultiobj, nonlcon MATLAB Answers — New Questions
Matrix dimensions must agree
Hello i am trying to use ‘pcolor’ command and error keeps popping up that ‘ matrix dimensions must agree ‘ i am a beginner and clueless on how to fix this if anyone could help id appreciate it , Thank you
ls *.asc
load(‘CTDGrpA1_conv_binav_asc.asc’)
load(‘CTDGrpA2_conv_binav_asc.asc’)
load(‘CTDGrpA3_conv_binav_asc.asc’)
load(‘CTDGrpA4_conv_binav_asc.asc’)
load(‘CTDGrpA5_conv_binav_asc.asc’)
load(‘CTDGrpA6_conv_binav_asc.asc’)
load(‘CTDGrpA7_conv_binav_asc.asc’)
load(‘CTDGrpA8_conv_binav_asc.asc’)
load(‘CTDGrpA9_conv_binav_asc.asc’)
T1=CTDGrpA1_conv_binav_asc(:,2);S1=CTDGrpA1_conv_binav_asc(:,3);depth1=CTDGrpA1_conv_binav_asc(:,1);
T2=CTDGrpA2_conv_binav_asc(1:13,2);S2=CTDGrpA2_conv_binav_asc(1:13,3);depth2=CTDGrpA2_conv_binav_asc(1:13,1);
T3=CTDGrpA3_conv_binav_asc(1:14,2);S3=CTDGrpA3_conv_binav_asc(1:14,3);depth3=CTDGrpA3_conv_binav_asc(1:14,1);
T4=CTDGrpA4_conv_binav_asc(1:14,2);S4=CTDGrpA4_conv_binav_asc(1:14,3);depth4=CTDGrpA4_conv_binav_asc(1:14,1);
T5=CTDGrpA5_conv_binav_asc(1:15,2);S5=CTDGrpA5_conv_binav_asc(1:15,3);depth5=CTDGrpA5_conv_binav_asc(1:15,1);
T6=CTDGrpA6_conv_binav_asc(1:12,2);S6=CTDGrpA6_conv_binav_asc(1:12,3);depth6=CTDGrpA6_conv_binav_asc(1:12,1);
T7=CTDGrpA7_conv_binav_asc(1:11,2);S7=CTDGrpA7_conv_binav_asc(1:11,3);depth7=CTDGrpA7_conv_binav_asc(1:11,1);
T8=CTDGrpA8_conv_binav_asc(1:8,2);S8=CTDGrpA8_conv_binav_asc(1:8,3);depth8=CTDGrpA8_conv_binav_asc(1:8,1);
T9=CTDGrpA9_conv_binav_asc(1:5,2);S9=CTDGrpA9_conv_binav_asc(1:5,3);depth9=CTDGrpA9_conv_binav_asc(1:5,1);
max_length=29;
Temperature1=[T1; nan(max_length-length(T1),1)];
Temperature2=[T2; nan(max_length-length(T2),1)];
Temperature3=[T3; nan(max_length-length(T3),1)];
Temperature4=[T4; nan(max_length-length(T4),1)];
Temperature5=[T5; nan(max_length-length(T5),1)];
Temperature6=[T6; nan(max_length-length(T6),1)];
Temperature7=[T7; nan(max_length-length(T7),1)];
Temperature8=[T8; nan(max_length-length(T8),1)];
Temperature9=[T9; nan(max_length-length(T9),1)];
whos Temperature*
Temperature_Matrix=[Temperature1 Temperature2 Temperature3 Temperature4 Temperature5 Temperature6 Temperature7 Temperature8 Temperature9];
Depth=depth5;
station=1:9;
figure
pcolor(station,Depth,Temperature_Matrix)Hello i am trying to use ‘pcolor’ command and error keeps popping up that ‘ matrix dimensions must agree ‘ i am a beginner and clueless on how to fix this if anyone could help id appreciate it , Thank you
ls *.asc
load(‘CTDGrpA1_conv_binav_asc.asc’)
load(‘CTDGrpA2_conv_binav_asc.asc’)
load(‘CTDGrpA3_conv_binav_asc.asc’)
load(‘CTDGrpA4_conv_binav_asc.asc’)
load(‘CTDGrpA5_conv_binav_asc.asc’)
load(‘CTDGrpA6_conv_binav_asc.asc’)
load(‘CTDGrpA7_conv_binav_asc.asc’)
load(‘CTDGrpA8_conv_binav_asc.asc’)
load(‘CTDGrpA9_conv_binav_asc.asc’)
T1=CTDGrpA1_conv_binav_asc(:,2);S1=CTDGrpA1_conv_binav_asc(:,3);depth1=CTDGrpA1_conv_binav_asc(:,1);
T2=CTDGrpA2_conv_binav_asc(1:13,2);S2=CTDGrpA2_conv_binav_asc(1:13,3);depth2=CTDGrpA2_conv_binav_asc(1:13,1);
T3=CTDGrpA3_conv_binav_asc(1:14,2);S3=CTDGrpA3_conv_binav_asc(1:14,3);depth3=CTDGrpA3_conv_binav_asc(1:14,1);
T4=CTDGrpA4_conv_binav_asc(1:14,2);S4=CTDGrpA4_conv_binav_asc(1:14,3);depth4=CTDGrpA4_conv_binav_asc(1:14,1);
T5=CTDGrpA5_conv_binav_asc(1:15,2);S5=CTDGrpA5_conv_binav_asc(1:15,3);depth5=CTDGrpA5_conv_binav_asc(1:15,1);
T6=CTDGrpA6_conv_binav_asc(1:12,2);S6=CTDGrpA6_conv_binav_asc(1:12,3);depth6=CTDGrpA6_conv_binav_asc(1:12,1);
T7=CTDGrpA7_conv_binav_asc(1:11,2);S7=CTDGrpA7_conv_binav_asc(1:11,3);depth7=CTDGrpA7_conv_binav_asc(1:11,1);
T8=CTDGrpA8_conv_binav_asc(1:8,2);S8=CTDGrpA8_conv_binav_asc(1:8,3);depth8=CTDGrpA8_conv_binav_asc(1:8,1);
T9=CTDGrpA9_conv_binav_asc(1:5,2);S9=CTDGrpA9_conv_binav_asc(1:5,3);depth9=CTDGrpA9_conv_binav_asc(1:5,1);
max_length=29;
Temperature1=[T1; nan(max_length-length(T1),1)];
Temperature2=[T2; nan(max_length-length(T2),1)];
Temperature3=[T3; nan(max_length-length(T3),1)];
Temperature4=[T4; nan(max_length-length(T4),1)];
Temperature5=[T5; nan(max_length-length(T5),1)];
Temperature6=[T6; nan(max_length-length(T6),1)];
Temperature7=[T7; nan(max_length-length(T7),1)];
Temperature8=[T8; nan(max_length-length(T8),1)];
Temperature9=[T9; nan(max_length-length(T9),1)];
whos Temperature*
Temperature_Matrix=[Temperature1 Temperature2 Temperature3 Temperature4 Temperature5 Temperature6 Temperature7 Temperature8 Temperature9];
Depth=depth5;
station=1:9;
figure
pcolor(station,Depth,Temperature_Matrix) Hello i am trying to use ‘pcolor’ command and error keeps popping up that ‘ matrix dimensions must agree ‘ i am a beginner and clueless on how to fix this if anyone could help id appreciate it , Thank you
ls *.asc
load(‘CTDGrpA1_conv_binav_asc.asc’)
load(‘CTDGrpA2_conv_binav_asc.asc’)
load(‘CTDGrpA3_conv_binav_asc.asc’)
load(‘CTDGrpA4_conv_binav_asc.asc’)
load(‘CTDGrpA5_conv_binav_asc.asc’)
load(‘CTDGrpA6_conv_binav_asc.asc’)
load(‘CTDGrpA7_conv_binav_asc.asc’)
load(‘CTDGrpA8_conv_binav_asc.asc’)
load(‘CTDGrpA9_conv_binav_asc.asc’)
T1=CTDGrpA1_conv_binav_asc(:,2);S1=CTDGrpA1_conv_binav_asc(:,3);depth1=CTDGrpA1_conv_binav_asc(:,1);
T2=CTDGrpA2_conv_binav_asc(1:13,2);S2=CTDGrpA2_conv_binav_asc(1:13,3);depth2=CTDGrpA2_conv_binav_asc(1:13,1);
T3=CTDGrpA3_conv_binav_asc(1:14,2);S3=CTDGrpA3_conv_binav_asc(1:14,3);depth3=CTDGrpA3_conv_binav_asc(1:14,1);
T4=CTDGrpA4_conv_binav_asc(1:14,2);S4=CTDGrpA4_conv_binav_asc(1:14,3);depth4=CTDGrpA4_conv_binav_asc(1:14,1);
T5=CTDGrpA5_conv_binav_asc(1:15,2);S5=CTDGrpA5_conv_binav_asc(1:15,3);depth5=CTDGrpA5_conv_binav_asc(1:15,1);
T6=CTDGrpA6_conv_binav_asc(1:12,2);S6=CTDGrpA6_conv_binav_asc(1:12,3);depth6=CTDGrpA6_conv_binav_asc(1:12,1);
T7=CTDGrpA7_conv_binav_asc(1:11,2);S7=CTDGrpA7_conv_binav_asc(1:11,3);depth7=CTDGrpA7_conv_binav_asc(1:11,1);
T8=CTDGrpA8_conv_binav_asc(1:8,2);S8=CTDGrpA8_conv_binav_asc(1:8,3);depth8=CTDGrpA8_conv_binav_asc(1:8,1);
T9=CTDGrpA9_conv_binav_asc(1:5,2);S9=CTDGrpA9_conv_binav_asc(1:5,3);depth9=CTDGrpA9_conv_binav_asc(1:5,1);
max_length=29;
Temperature1=[T1; nan(max_length-length(T1),1)];
Temperature2=[T2; nan(max_length-length(T2),1)];
Temperature3=[T3; nan(max_length-length(T3),1)];
Temperature4=[T4; nan(max_length-length(T4),1)];
Temperature5=[T5; nan(max_length-length(T5),1)];
Temperature6=[T6; nan(max_length-length(T6),1)];
Temperature7=[T7; nan(max_length-length(T7),1)];
Temperature8=[T8; nan(max_length-length(T8),1)];
Temperature9=[T9; nan(max_length-length(T9),1)];
whos Temperature*
Temperature_Matrix=[Temperature1 Temperature2 Temperature3 Temperature4 Temperature5 Temperature6 Temperature7 Temperature8 Temperature9];
Depth=depth5;
station=1:9;
figure
pcolor(station,Depth,Temperature_Matrix) error matrix MATLAB Answers — New Questions
How can I specify the pressure and or the temperature for a specific point in a thermal liquid network ?
Hello everyone
I was wondering wether using a reservoir (TL) is a good choice or not. Thank you in advanceHello everyone
I was wondering wether using a reservoir (TL) is a good choice or not. Thank you in advance Hello everyone
I was wondering wether using a reservoir (TL) is a good choice or not. Thank you in advance simscape, simulink, simulation, model, matlab MATLAB Answers — New Questions
Errors in turbulent image analysis.
Hello, I am analyzing images of turbulent for a school assignment.
The code below is the code I learned, but an error occurs at lines 5 and 11. Thank you for letting me know where I went wrong.
Thank you and have a good day:)
(Plus, I have attached a photo for analysis below.)
clc; clear all, close all;
I = imread(‘301.png’);
I = rgb2gray(I);
I = I(120:840, 850:1320);%ERROR
figure(1)
imshow(I);
title(‘original image’);
[~,threshold] = edge(I,’sobel’);%ERROR
fudgeFactor = 0.7;
BWs = edge(I,’sobel’,threshold*fudgeFactor);
figure(2)
imshow(BWs);
Title(‘gradient’);
se1 = streal(‘line’,3,90);
se0 = streal(‘line’,3,0);
BWsdil = imdilate(BWs,[se1 se0]);
figure(3)
imshow(Bwsdil);
figure(4)
imshow(labeloverlay(I,BWdil));Hello, I am analyzing images of turbulent for a school assignment.
The code below is the code I learned, but an error occurs at lines 5 and 11. Thank you for letting me know where I went wrong.
Thank you and have a good day:)
(Plus, I have attached a photo for analysis below.)
clc; clear all, close all;
I = imread(‘301.png’);
I = rgb2gray(I);
I = I(120:840, 850:1320);%ERROR
figure(1)
imshow(I);
title(‘original image’);
[~,threshold] = edge(I,’sobel’);%ERROR
fudgeFactor = 0.7;
BWs = edge(I,’sobel’,threshold*fudgeFactor);
figure(2)
imshow(BWs);
Title(‘gradient’);
se1 = streal(‘line’,3,90);
se0 = streal(‘line’,3,0);
BWsdil = imdilate(BWs,[se1 se0]);
figure(3)
imshow(Bwsdil);
figure(4)
imshow(labeloverlay(I,BWdil)); Hello, I am analyzing images of turbulent for a school assignment.
The code below is the code I learned, but an error occurs at lines 5 and 11. Thank you for letting me know where I went wrong.
Thank you and have a good day:)
(Plus, I have attached a photo for analysis below.)
clc; clear all, close all;
I = imread(‘301.png’);
I = rgb2gray(I);
I = I(120:840, 850:1320);%ERROR
figure(1)
imshow(I);
title(‘original image’);
[~,threshold] = edge(I,’sobel’);%ERROR
fudgeFactor = 0.7;
BWs = edge(I,’sobel’,threshold*fudgeFactor);
figure(2)
imshow(BWs);
Title(‘gradient’);
se1 = streal(‘line’,3,90);
se0 = streal(‘line’,3,0);
BWsdil = imdilate(BWs,[se1 se0]);
figure(3)
imshow(Bwsdil);
figure(4)
imshow(labeloverlay(I,BWdil)); turbulent, turbulence, image analysis MATLAB Answers — New Questions