Category: Matlab
Category Archives: Matlab
Axis does not plot in app designer
I am making an application in app designer where I use two graphs to show the PWM of a digital controller, the UIAxes of the controller response works fine, but the PWM does not show the graph even when the axes are updated normally.
usada = app.PlacaDropDown.Value;
pcom = app.PuertoCOMEditField.Value;
elcom = strcat(‘COM’, pcom);
app.a = arduino(elcom, usada);
app.parar = false;
app.file_path = uiputfile(‘*.csv’, ‘Guardar como’);
i = 1;
H1 = 0;
H2 = 0;
selectedTab = app.TabGroup.SelectedTab;
titulo = selectedTab.Title;
switch titulo
case ‘P’
K = app.K_P.Value;
t = app.T_P.Value;
q0 = K;
q1 = 0.0;
q2 = 0.0;
case ‘PI’
K = app.K_PI.Value;
Ti = app.Ti_PI.Value;
t = app.T_PI.Value;
q0 = K * ( 1 + t/2*Ti );
q1 = -K * ( 1 – t/2*Ti );
q2 = 0.0;
case ‘PID’
K = app.K_PID.Value;
Ti = app.Ti_PID.Value;
Td = app.Td_PID.Value;
t = app.T_PID.Value;
q0 = K * (1 + t/2*Ti + Td/t );
q1 = -K * (1 – t/2*Ti + 2*Td/t );
q2 = K*Td/t;
end
while ~app.parar
muestra(i) = i;
lectura1(i) = readVoltage(app.a,’A1′)* 25;
lectura2(i) = readVoltage(app.a,’A2′)* 25;
if lectura1 >= 40
writeDigitalPin(app.a, ‘D7’, 1);
else
writeDigitalPin(app.a, ‘D7’, 0);
end
if lectura2 >= 40
writeDigitalPin(app.a,’D8′,1);
else
writeDigitalPin(app.a, ‘D8’, 0);
end
if app.Q1CheckBox.Value
%Actualizacion del vector de error (etapa 1).
app.e1(1) = app.e1(2);
app.e1(2) = app.e1(3);
app.e1(3) = app.tempRef.Value – lectura1(i);
%Actualizacion del vector de control (etapa 1).
app.u1(1) = app.u1(2);
app.u1(2) = ControlPID(app.u1, app.e1, q0, q1, q2);
H1 = app.u1(2) / 100; %Se mapea el PWM obtenico para enviarlo al arduino.
writePWMDutyCycle(app.a, ‘D11’, H1);
end
if app.Q2CheckBox.Value
%Actualizacion del vector de error (etapa 2).
app.e2(1) = app.e2(2);
app.e2(2) = app.e2(3);
app.e2(3) = app.tempRef.Value – lectura2(i);
%Actualizacion del vector de control (etapa 2).
app.u2(1) = app.u2(2);
app.u2(2) = ControlPID(app.u2, app.e2, q0, q1, q2);
H2 = app.u2(2) / 100; %Se mapea el PWM obtenico para enviarlo al arduino.
writePWMDutyCycle(app.a, ‘D10’, H2);
end
format bank;
app.matriz1(1, 1) = muestra(i);
app.matriz1(1, 2) = round(lectura1(i), 2);
app.matriz1(1, 3) = round(lectura2(i), 2);
app.matriz1(1, 4) = round(H1 * 100, 2);
app.matriz1(1, 5) = round(H2 * 100, 2);
writematrix(app.matriz1, app.file_path, ‘WriteMode’, ‘append’);
plot(app.grafica_pwm, muestra(i), H2 * 100, muestra(i), H1 * 100);
legend(app.grafica_pwm, ‘H2’, ‘H1’);
plot(app.grafica_temp, muestra, lectura2, muestra, lectura1);
legend(app.grafica_temp, ‘Lectura2’, ‘Lectura1’);
drawnow;
i = i + 1;
%set(app.inicioButton,’BackgroundColor’,[0 0 0],’FontColor’,[0.96 0.96 0.96],’Text’,’Sensando…’);
pause(t);
end
function [act] = ControlPID(u, e, q0, q1, q2)
act = u(1) + q0*e(3) + q1*e(2) + q2*e(1);
if act >= 100
act = 100;
elseif act <= 0
act = 0;
end
end
I am grateful for any commentsI am making an application in app designer where I use two graphs to show the PWM of a digital controller, the UIAxes of the controller response works fine, but the PWM does not show the graph even when the axes are updated normally.
usada = app.PlacaDropDown.Value;
pcom = app.PuertoCOMEditField.Value;
elcom = strcat(‘COM’, pcom);
app.a = arduino(elcom, usada);
app.parar = false;
app.file_path = uiputfile(‘*.csv’, ‘Guardar como’);
i = 1;
H1 = 0;
H2 = 0;
selectedTab = app.TabGroup.SelectedTab;
titulo = selectedTab.Title;
switch titulo
case ‘P’
K = app.K_P.Value;
t = app.T_P.Value;
q0 = K;
q1 = 0.0;
q2 = 0.0;
case ‘PI’
K = app.K_PI.Value;
Ti = app.Ti_PI.Value;
t = app.T_PI.Value;
q0 = K * ( 1 + t/2*Ti );
q1 = -K * ( 1 – t/2*Ti );
q2 = 0.0;
case ‘PID’
K = app.K_PID.Value;
Ti = app.Ti_PID.Value;
Td = app.Td_PID.Value;
t = app.T_PID.Value;
q0 = K * (1 + t/2*Ti + Td/t );
q1 = -K * (1 – t/2*Ti + 2*Td/t );
q2 = K*Td/t;
end
while ~app.parar
muestra(i) = i;
lectura1(i) = readVoltage(app.a,’A1′)* 25;
lectura2(i) = readVoltage(app.a,’A2′)* 25;
if lectura1 >= 40
writeDigitalPin(app.a, ‘D7’, 1);
else
writeDigitalPin(app.a, ‘D7’, 0);
end
if lectura2 >= 40
writeDigitalPin(app.a,’D8′,1);
else
writeDigitalPin(app.a, ‘D8’, 0);
end
if app.Q1CheckBox.Value
%Actualizacion del vector de error (etapa 1).
app.e1(1) = app.e1(2);
app.e1(2) = app.e1(3);
app.e1(3) = app.tempRef.Value – lectura1(i);
%Actualizacion del vector de control (etapa 1).
app.u1(1) = app.u1(2);
app.u1(2) = ControlPID(app.u1, app.e1, q0, q1, q2);
H1 = app.u1(2) / 100; %Se mapea el PWM obtenico para enviarlo al arduino.
writePWMDutyCycle(app.a, ‘D11’, H1);
end
if app.Q2CheckBox.Value
%Actualizacion del vector de error (etapa 2).
app.e2(1) = app.e2(2);
app.e2(2) = app.e2(3);
app.e2(3) = app.tempRef.Value – lectura2(i);
%Actualizacion del vector de control (etapa 2).
app.u2(1) = app.u2(2);
app.u2(2) = ControlPID(app.u2, app.e2, q0, q1, q2);
H2 = app.u2(2) / 100; %Se mapea el PWM obtenico para enviarlo al arduino.
writePWMDutyCycle(app.a, ‘D10’, H2);
end
format bank;
app.matriz1(1, 1) = muestra(i);
app.matriz1(1, 2) = round(lectura1(i), 2);
app.matriz1(1, 3) = round(lectura2(i), 2);
app.matriz1(1, 4) = round(H1 * 100, 2);
app.matriz1(1, 5) = round(H2 * 100, 2);
writematrix(app.matriz1, app.file_path, ‘WriteMode’, ‘append’);
plot(app.grafica_pwm, muestra(i), H2 * 100, muestra(i), H1 * 100);
legend(app.grafica_pwm, ‘H2’, ‘H1’);
plot(app.grafica_temp, muestra, lectura2, muestra, lectura1);
legend(app.grafica_temp, ‘Lectura2’, ‘Lectura1’);
drawnow;
i = i + 1;
%set(app.inicioButton,’BackgroundColor’,[0 0 0],’FontColor’,[0.96 0.96 0.96],’Text’,’Sensando…’);
pause(t);
end
function [act] = ControlPID(u, e, q0, q1, q2)
act = u(1) + q0*e(3) + q1*e(2) + q2*e(1);
if act >= 100
act = 100;
elseif act <= 0
act = 0;
end
end
I am grateful for any comments I am making an application in app designer where I use two graphs to show the PWM of a digital controller, the UIAxes of the controller response works fine, but the PWM does not show the graph even when the axes are updated normally.
usada = app.PlacaDropDown.Value;
pcom = app.PuertoCOMEditField.Value;
elcom = strcat(‘COM’, pcom);
app.a = arduino(elcom, usada);
app.parar = false;
app.file_path = uiputfile(‘*.csv’, ‘Guardar como’);
i = 1;
H1 = 0;
H2 = 0;
selectedTab = app.TabGroup.SelectedTab;
titulo = selectedTab.Title;
switch titulo
case ‘P’
K = app.K_P.Value;
t = app.T_P.Value;
q0 = K;
q1 = 0.0;
q2 = 0.0;
case ‘PI’
K = app.K_PI.Value;
Ti = app.Ti_PI.Value;
t = app.T_PI.Value;
q0 = K * ( 1 + t/2*Ti );
q1 = -K * ( 1 – t/2*Ti );
q2 = 0.0;
case ‘PID’
K = app.K_PID.Value;
Ti = app.Ti_PID.Value;
Td = app.Td_PID.Value;
t = app.T_PID.Value;
q0 = K * (1 + t/2*Ti + Td/t );
q1 = -K * (1 – t/2*Ti + 2*Td/t );
q2 = K*Td/t;
end
while ~app.parar
muestra(i) = i;
lectura1(i) = readVoltage(app.a,’A1′)* 25;
lectura2(i) = readVoltage(app.a,’A2′)* 25;
if lectura1 >= 40
writeDigitalPin(app.a, ‘D7’, 1);
else
writeDigitalPin(app.a, ‘D7’, 0);
end
if lectura2 >= 40
writeDigitalPin(app.a,’D8′,1);
else
writeDigitalPin(app.a, ‘D8’, 0);
end
if app.Q1CheckBox.Value
%Actualizacion del vector de error (etapa 1).
app.e1(1) = app.e1(2);
app.e1(2) = app.e1(3);
app.e1(3) = app.tempRef.Value – lectura1(i);
%Actualizacion del vector de control (etapa 1).
app.u1(1) = app.u1(2);
app.u1(2) = ControlPID(app.u1, app.e1, q0, q1, q2);
H1 = app.u1(2) / 100; %Se mapea el PWM obtenico para enviarlo al arduino.
writePWMDutyCycle(app.a, ‘D11’, H1);
end
if app.Q2CheckBox.Value
%Actualizacion del vector de error (etapa 2).
app.e2(1) = app.e2(2);
app.e2(2) = app.e2(3);
app.e2(3) = app.tempRef.Value – lectura2(i);
%Actualizacion del vector de control (etapa 2).
app.u2(1) = app.u2(2);
app.u2(2) = ControlPID(app.u2, app.e2, q0, q1, q2);
H2 = app.u2(2) / 100; %Se mapea el PWM obtenico para enviarlo al arduino.
writePWMDutyCycle(app.a, ‘D10’, H2);
end
format bank;
app.matriz1(1, 1) = muestra(i);
app.matriz1(1, 2) = round(lectura1(i), 2);
app.matriz1(1, 3) = round(lectura2(i), 2);
app.matriz1(1, 4) = round(H1 * 100, 2);
app.matriz1(1, 5) = round(H2 * 100, 2);
writematrix(app.matriz1, app.file_path, ‘WriteMode’, ‘append’);
plot(app.grafica_pwm, muestra(i), H2 * 100, muestra(i), H1 * 100);
legend(app.grafica_pwm, ‘H2’, ‘H1’);
plot(app.grafica_temp, muestra, lectura2, muestra, lectura1);
legend(app.grafica_temp, ‘Lectura2’, ‘Lectura1’);
drawnow;
i = i + 1;
%set(app.inicioButton,’BackgroundColor’,[0 0 0],’FontColor’,[0.96 0.96 0.96],’Text’,’Sensando…’);
pause(t);
end
function [act] = ControlPID(u, e, q0, q1, q2)
act = u(1) + q0*e(3) + q1*e(2) + q2*e(1);
if act >= 100
act = 100;
elseif act <= 0
act = 0;
end
end
I am grateful for any comments appdesigner, axes MATLAB Answers — New Questions
Random Number from a given vector of numbers
Given a vector of certain allowed numbers,
how to generate another vector whose elements randomly take values from that vector of numbers?Given a vector of certain allowed numbers,
how to generate another vector whose elements randomly take values from that vector of numbers? Given a vector of certain allowed numbers,
how to generate another vector whose elements randomly take values from that vector of numbers? random MATLAB Answers — New Questions
Using signal values in a block that accepts variables in Simscape Multibody
Hi there,
I want to create a frame at the centroid of a bunch of frame origins. I tracked these frames through the Transform Sensor block, and calculated the coordinates of the centroid. Now, I can’t seem to figure out how to use these x,y,z coordinates in the rigid transform block (B frame will be connected to the fixed reference) so that F frame is translated in space by x,y,z amounts in the respective directions.
Can’t I use these signal inputs in the block (like [x_coord y_coord z_coord] in the place of [0 0 0])?
Any help is highly appreciated. Thank you.Hi there,
I want to create a frame at the centroid of a bunch of frame origins. I tracked these frames through the Transform Sensor block, and calculated the coordinates of the centroid. Now, I can’t seem to figure out how to use these x,y,z coordinates in the rigid transform block (B frame will be connected to the fixed reference) so that F frame is translated in space by x,y,z amounts in the respective directions.
Can’t I use these signal inputs in the block (like [x_coord y_coord z_coord] in the place of [0 0 0])?
Any help is highly appreciated. Thank you. Hi there,
I want to create a frame at the centroid of a bunch of frame origins. I tracked these frames through the Transform Sensor block, and calculated the coordinates of the centroid. Now, I can’t seem to figure out how to use these x,y,z coordinates in the rigid transform block (B frame will be connected to the fixed reference) so that F frame is translated in space by x,y,z amounts in the respective directions.
Can’t I use these signal inputs in the block (like [x_coord y_coord z_coord] in the place of [0 0 0])?
Any help is highly appreciated. Thank you. simscape, signals, variables, rigid transform, coordinates MATLAB Answers — New Questions
Extracting values from optimization variable and setting constraints
I have a basket of 20 products with baseline quantities E.g., 40 Tomatoes, 15 Onions, 35 Apples etc. Standard linear optimization with the objective being maximizing the value of the basket subject to constraints on the total weight of the basket, total number of items etc.
The optimization variable QTY is used by the optimizer to adjust the baseline quantity for each product. QTY can take integer values of -15 to +15, i.e., it can increase or reduce baseline amounts of each product by 5 units.
For reasons outside the scope of this question, I need to limit the total number of adjustments it makes across all products, i.e., the sum of the absolute value of QTY <= 30. So it can’t reduce Tomatoes and Onions by 10 each but increase Apples by 15.
How do I place this constraint?
The ABS function can’t access the values in QTY. Adding the constraint on the squared value of QTY gives me a "nonlinear problem" error. Assigning values in QTY to another variable doesn’t work since it just aliases. Various other attempts have yielded the same "nonlinear" error. I’ve been able to make it work in the past by setting 2 optimization variables – QTYUP and QTYDOWN but that becomes clunky.
Current thought is to find a way to extract the values in QTY into a temporary variable, calculate the sum of absolute values, and go. But I haven’t found a straightforward way to this.
Thanks.I have a basket of 20 products with baseline quantities E.g., 40 Tomatoes, 15 Onions, 35 Apples etc. Standard linear optimization with the objective being maximizing the value of the basket subject to constraints on the total weight of the basket, total number of items etc.
The optimization variable QTY is used by the optimizer to adjust the baseline quantity for each product. QTY can take integer values of -15 to +15, i.e., it can increase or reduce baseline amounts of each product by 5 units.
For reasons outside the scope of this question, I need to limit the total number of adjustments it makes across all products, i.e., the sum of the absolute value of QTY <= 30. So it can’t reduce Tomatoes and Onions by 10 each but increase Apples by 15.
How do I place this constraint?
The ABS function can’t access the values in QTY. Adding the constraint on the squared value of QTY gives me a "nonlinear problem" error. Assigning values in QTY to another variable doesn’t work since it just aliases. Various other attempts have yielded the same "nonlinear" error. I’ve been able to make it work in the past by setting 2 optimization variables – QTYUP and QTYDOWN but that becomes clunky.
Current thought is to find a way to extract the values in QTY into a temporary variable, calculate the sum of absolute values, and go. But I haven’t found a straightforward way to this.
Thanks. I have a basket of 20 products with baseline quantities E.g., 40 Tomatoes, 15 Onions, 35 Apples etc. Standard linear optimization with the objective being maximizing the value of the basket subject to constraints on the total weight of the basket, total number of items etc.
The optimization variable QTY is used by the optimizer to adjust the baseline quantity for each product. QTY can take integer values of -15 to +15, i.e., it can increase or reduce baseline amounts of each product by 5 units.
For reasons outside the scope of this question, I need to limit the total number of adjustments it makes across all products, i.e., the sum of the absolute value of QTY <= 30. So it can’t reduce Tomatoes and Onions by 10 each but increase Apples by 15.
How do I place this constraint?
The ABS function can’t access the values in QTY. Adding the constraint on the squared value of QTY gives me a "nonlinear problem" error. Assigning values in QTY to another variable doesn’t work since it just aliases. Various other attempts have yielded the same "nonlinear" error. I’ve been able to make it work in the past by setting 2 optimization variables – QTYUP and QTYDOWN but that becomes clunky.
Current thought is to find a way to extract the values in QTY into a temporary variable, calculate the sum of absolute values, and go. But I haven’t found a straightforward way to this.
Thanks. optimization, constraints MATLAB Answers — New Questions
command not found: pip
Python is installed and loaded in Matlab but pip is not found
how can I fix this?
>> pyenv
ans =
PythonEnvironment with properties:
Version: "3.9"
Executable: "/Library/Developer/CommandLineTools/usr/bin/python3"
Library: "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/libpython3.9.dylib"
Home: "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9"
Status: Loaded
ExecutionMode: InProcess
ProcessID: "17092"
ProcessName: "MATLAB"
>> !pip install tensorflow
zsh:1: command not found: pipPython is installed and loaded in Matlab but pip is not found
how can I fix this?
>> pyenv
ans =
PythonEnvironment with properties:
Version: "3.9"
Executable: "/Library/Developer/CommandLineTools/usr/bin/python3"
Library: "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/libpython3.9.dylib"
Home: "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9"
Status: Loaded
ExecutionMode: InProcess
ProcessID: "17092"
ProcessName: "MATLAB"
>> !pip install tensorflow
zsh:1: command not found: pip Python is installed and loaded in Matlab but pip is not found
how can I fix this?
>> pyenv
ans =
PythonEnvironment with properties:
Version: "3.9"
Executable: "/Library/Developer/CommandLineTools/usr/bin/python3"
Library: "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/libpython3.9.dylib"
Home: "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9"
Status: Loaded
ExecutionMode: InProcess
ProcessID: "17092"
ProcessName: "MATLAB"
>> !pip install tensorflow
zsh:1: command not found: pip python MATLAB Answers — New Questions
Designing Coffee vending Machine using Simulink MATLAB
I am trying to build a coffee vending machine in the simulink for MATLAB but I can’t find any resoruces related to the topic can anyone help me.I am trying to build a coffee vending machine in the simulink for MATLAB but I can’t find any resoruces related to the topic can anyone help me. I am trying to build a coffee vending machine in the simulink for MATLAB but I can’t find any resoruces related to the topic can anyone help me. simulink, matlab MATLAB Answers — New Questions
Readtable is not reading all of my Data
I am trying to use readtable to read a large excel file (5185 rows) and sometimes this excel file will have columns 21 & 22 empty other then the title up until the 3000+ lines. When this is the case the entire column of 21 & 22 has <missing> as its variable. I assume that after a certain amount of rows the readtable just assumes that the rest of the column is empty. For example, when there are values stored in those columns starting at row 148 it will properly read the data and <missing> does not come up anywhere. Does anyone know a way that can bypass this assumption?
This is the code I am using to read the excel data:
FileName_excel_Results = sprintf(‘SmartChipData_A%06i%s_Results.xlsx’, app.ChipIDEditField.Value, app.dropdown.Value);
fullFileName_excel_Results = fullfile(app.result_filepath, FileName_excel_Results);
t = readtable(fullFileName_excel_Results, ‘Sheet’,’Summary’,’ExpectedNumVariables’,23); % storing the Selected_Spots excel
summary = table2cell(t);
disp(string(summary(3196,:)));
Here is the output I get from the Disp:
Columns 1 through 7
"3195" "45" "28" "45" "C:UsersSingle C…" "C:UsersSingle C…" "[0,0,0]"
Columns 8 through 17
"45/28" "0" "0" "1" "-1" "-1" "-1" "Auto" "A" "i7-28"
Columns 18 through 23
"CGATAACTGGTCTTAAG…" "i5-45" "TAAAGTAGTAAAGTAGG…" <missing> <missing> "47"
This is what is stored in that row from the excel sheet:
3195 45 28 45 C:UsersSingle Cell ScopeDesktopChip143881CyanS0000C45R45_C45_0000_00_Cyan.tif C:UsersSingle Cell ScopeDesktopChip143881GreenS0000C45R45_C45_0000_01_Green.tif [0,0,0] 45/28 0 0 1 -1 -1-1 Auto A i7-28 CGATAACTGGTCTTAAGATGTGAA i5-45 TAAAGTAGTAAAGTAGGATTCTCT C1 1A1 47I am trying to use readtable to read a large excel file (5185 rows) and sometimes this excel file will have columns 21 & 22 empty other then the title up until the 3000+ lines. When this is the case the entire column of 21 & 22 has <missing> as its variable. I assume that after a certain amount of rows the readtable just assumes that the rest of the column is empty. For example, when there are values stored in those columns starting at row 148 it will properly read the data and <missing> does not come up anywhere. Does anyone know a way that can bypass this assumption?
This is the code I am using to read the excel data:
FileName_excel_Results = sprintf(‘SmartChipData_A%06i%s_Results.xlsx’, app.ChipIDEditField.Value, app.dropdown.Value);
fullFileName_excel_Results = fullfile(app.result_filepath, FileName_excel_Results);
t = readtable(fullFileName_excel_Results, ‘Sheet’,’Summary’,’ExpectedNumVariables’,23); % storing the Selected_Spots excel
summary = table2cell(t);
disp(string(summary(3196,:)));
Here is the output I get from the Disp:
Columns 1 through 7
"3195" "45" "28" "45" "C:UsersSingle C…" "C:UsersSingle C…" "[0,0,0]"
Columns 8 through 17
"45/28" "0" "0" "1" "-1" "-1" "-1" "Auto" "A" "i7-28"
Columns 18 through 23
"CGATAACTGGTCTTAAG…" "i5-45" "TAAAGTAGTAAAGTAGG…" <missing> <missing> "47"
This is what is stored in that row from the excel sheet:
3195 45 28 45 C:UsersSingle Cell ScopeDesktopChip143881CyanS0000C45R45_C45_0000_00_Cyan.tif C:UsersSingle Cell ScopeDesktopChip143881GreenS0000C45R45_C45_0000_01_Green.tif [0,0,0] 45/28 0 0 1 -1 -1-1 Auto A i7-28 CGATAACTGGTCTTAAGATGTGAA i5-45 TAAAGTAGTAAAGTAGGATTCTCT C1 1A1 47 I am trying to use readtable to read a large excel file (5185 rows) and sometimes this excel file will have columns 21 & 22 empty other then the title up until the 3000+ lines. When this is the case the entire column of 21 & 22 has <missing> as its variable. I assume that after a certain amount of rows the readtable just assumes that the rest of the column is empty. For example, when there are values stored in those columns starting at row 148 it will properly read the data and <missing> does not come up anywhere. Does anyone know a way that can bypass this assumption?
This is the code I am using to read the excel data:
FileName_excel_Results = sprintf(‘SmartChipData_A%06i%s_Results.xlsx’, app.ChipIDEditField.Value, app.dropdown.Value);
fullFileName_excel_Results = fullfile(app.result_filepath, FileName_excel_Results);
t = readtable(fullFileName_excel_Results, ‘Sheet’,’Summary’,’ExpectedNumVariables’,23); % storing the Selected_Spots excel
summary = table2cell(t);
disp(string(summary(3196,:)));
Here is the output I get from the Disp:
Columns 1 through 7
"3195" "45" "28" "45" "C:UsersSingle C…" "C:UsersSingle C…" "[0,0,0]"
Columns 8 through 17
"45/28" "0" "0" "1" "-1" "-1" "-1" "Auto" "A" "i7-28"
Columns 18 through 23
"CGATAACTGGTCTTAAG…" "i5-45" "TAAAGTAGTAAAGTAGG…" <missing> <missing> "47"
This is what is stored in that row from the excel sheet:
3195 45 28 45 C:UsersSingle Cell ScopeDesktopChip143881CyanS0000C45R45_C45_0000_00_Cyan.tif C:UsersSingle Cell ScopeDesktopChip143881GreenS0000C45R45_C45_0000_01_Green.tif [0,0,0] 45/28 0 0 1 -1 -1-1 Auto A i7-28 CGATAACTGGTCTTAAGATGTGAA i5-45 TAAAGTAGTAAAGTAGGATTCTCT C1 1A1 47 importing excel data, data import MATLAB Answers — New Questions
Obtaining the proportional, derivative and integral gains from a specific settling time and overshoot inputted using a Simulink block diagram
I need to find the PID gains that are obtained from a 10% overshoot and a 10 second settling time from the block diagram system attached. every resource I use online points me to PID Tuner App and it doesn’t seem to have a tool which can set the overshoot and settling time to specific values and I have been running into a lot of issuesI need to find the PID gains that are obtained from a 10% overshoot and a 10 second settling time from the block diagram system attached. every resource I use online points me to PID Tuner App and it doesn’t seem to have a tool which can set the overshoot and settling time to specific values and I have been running into a lot of issues I need to find the PID gains that are obtained from a 10% overshoot and a 10 second settling time from the block diagram system attached. every resource I use online points me to PID Tuner App and it doesn’t seem to have a tool which can set the overshoot and settling time to specific values and I have been running into a lot of issues pid control, simulink MATLAB Answers — New Questions
Having issues writing matrix to a binary file.
For example,
A = [ 0.1712 0.2769 0.8235
0.7060 0.0462 0.6948
0.0318 0.0971 0.3171]
file1 = ‘mat1.dat’
fileID = fopen(file1, ‘w’);
fwrite(fileID, size(data1), ‘int32’);
fwrite(fileID, data1, ‘double’)
fclose("all")
Using this code, the matrix size remains the same, but when I read it, the last row gets messed up, for example, see the output below:
0.0000 0.0318 0.0971
0.1712 0.2769 0.8235
0.7060 0.0462 0.6948
>> Anyone knows how to fix this?For example,
A = [ 0.1712 0.2769 0.8235
0.7060 0.0462 0.6948
0.0318 0.0971 0.3171]
file1 = ‘mat1.dat’
fileID = fopen(file1, ‘w’);
fwrite(fileID, size(data1), ‘int32’);
fwrite(fileID, data1, ‘double’)
fclose("all")
Using this code, the matrix size remains the same, but when I read it, the last row gets messed up, for example, see the output below:
0.0000 0.0318 0.0971
0.1712 0.2769 0.8235
0.7060 0.0462 0.6948
>> Anyone knows how to fix this? For example,
A = [ 0.1712 0.2769 0.8235
0.7060 0.0462 0.6948
0.0318 0.0971 0.3171]
file1 = ‘mat1.dat’
fileID = fopen(file1, ‘w’);
fwrite(fileID, size(data1), ‘int32’);
fwrite(fileID, data1, ‘double’)
fclose("all")
Using this code, the matrix size remains the same, but when I read it, the last row gets messed up, for example, see the output below:
0.0000 0.0318 0.0971
0.1712 0.2769 0.8235
0.7060 0.0462 0.6948
>> Anyone knows how to fix this? binary, matrix, fread, fwrite MATLAB Answers — New Questions
How can I move an object in Simscape Multibody in 6DOF with position inputs?
I have a project which I need to simulate an UAV in Simscape Multibody environment. I used "6-DOF Joint" block for this purpose however,I can use position inputs for only translational motion. For rotational motion there is only one actuation option which is torque. I want to provide the angles directly. Is there a way to do that?I have a project which I need to simulate an UAV in Simscape Multibody environment. I used "6-DOF Joint" block for this purpose however,I can use position inputs for only translational motion. For rotational motion there is only one actuation option which is torque. I want to provide the angles directly. Is there a way to do that? I have a project which I need to simulate an UAV in Simscape Multibody environment. I used "6-DOF Joint" block for this purpose however,I can use position inputs for only translational motion. For rotational motion there is only one actuation option which is torque. I want to provide the angles directly. Is there a way to do that? simscape, multibody MATLAB Answers — New Questions
does anyone have matlab code for routing of underwater wireless sensor networks?
I am finding the codes for any routing protocol of underwater wsn for my m.tech thesis.I am finding the codes for any routing protocol of underwater wsn for my m.tech thesis. I am finding the codes for any routing protocol of underwater wsn for my m.tech thesis. matlab MATLAB Answers — New Questions
I want to graph a voltage and current of each of my elements. please help me
Post Content Post Content electrical networks MATLAB Answers — New Questions
Access to Matlab 2018a version?
Hey guys, I’m trying to run code that someone else wrote on the 2018a version of Matlab. It won’t run on the 2022 version on my PC. Does anyone know of a safe website to download the 2018a version of Matlab? I’m hoping this will solve the problem. Thanks.Hey guys, I’m trying to run code that someone else wrote on the 2018a version of Matlab. It won’t run on the 2022 version on my PC. Does anyone know of a safe website to download the 2018a version of Matlab? I’m hoping this will solve the problem. Thanks. Hey guys, I’m trying to run code that someone else wrote on the 2018a version of Matlab. It won’t run on the 2022 version on my PC. Does anyone know of a safe website to download the 2018a version of Matlab? I’m hoping this will solve the problem. Thanks. matlab 2018a MATLAB Answers — New Questions
what type of error is this? is this the logical error, simulation error, code error?
what type of error is this? is this the logical error, simulation error, code error?what type of error is this? is this the logical error, simulation error, code error? what type of error is this? is this the logical error, simulation error, code error? what type of error is this? is this the logical er MATLAB Answers — New Questions
Can’t identify hadoop home from Matlab to use Matlab Parallel Toolbox.
I have Matlab2014b + Hadoop installed. The hadoop works well on my CentOS Linux system.
I run the mablab on that CentOS Linux machine. With the commands as follows.
It shows the folder is not a valid Hadop no matter how to change it ( I tried set the directory with hadoop 1.2.1, hadoop 2.5.2, hadoop cloudera distribution; also tried with parameter HADOOP_PREFIX,HADOOP_HOME,MATLAB_HADOOP_INSTALL ).
Anything else I can do to fix this error ?
>> setenv(‘MATLAB_HADOOP_INSTALL’,’/mnt/disk1/data/soft/hadoop-2.5.2′);
>> cluster = parallel.cluster.Hadoop;
Error using parallel.cluster.Hadoop (line 107)
Unable to recognize ‘/mnt/disk1/data/soft/hadoop-2.5.2’ as a valid HADOOP
installation folder. Check that this is the root of your HADOOP installation
folder.
Thanks and Best Wishes.
XinsongI have Matlab2014b + Hadoop installed. The hadoop works well on my CentOS Linux system.
I run the mablab on that CentOS Linux machine. With the commands as follows.
It shows the folder is not a valid Hadop no matter how to change it ( I tried set the directory with hadoop 1.2.1, hadoop 2.5.2, hadoop cloudera distribution; also tried with parameter HADOOP_PREFIX,HADOOP_HOME,MATLAB_HADOOP_INSTALL ).
Anything else I can do to fix this error ?
>> setenv(‘MATLAB_HADOOP_INSTALL’,’/mnt/disk1/data/soft/hadoop-2.5.2′);
>> cluster = parallel.cluster.Hadoop;
Error using parallel.cluster.Hadoop (line 107)
Unable to recognize ‘/mnt/disk1/data/soft/hadoop-2.5.2’ as a valid HADOOP
installation folder. Check that this is the root of your HADOOP installation
folder.
Thanks and Best Wishes.
Xinsong I have Matlab2014b + Hadoop installed. The hadoop works well on my CentOS Linux system.
I run the mablab on that CentOS Linux machine. With the commands as follows.
It shows the folder is not a valid Hadop no matter how to change it ( I tried set the directory with hadoop 1.2.1, hadoop 2.5.2, hadoop cloudera distribution; also tried with parameter HADOOP_PREFIX,HADOOP_HOME,MATLAB_HADOOP_INSTALL ).
Anything else I can do to fix this error ?
>> setenv(‘MATLAB_HADOOP_INSTALL’,’/mnt/disk1/data/soft/hadoop-2.5.2′);
>> cluster = parallel.cluster.Hadoop;
Error using parallel.cluster.Hadoop (line 107)
Unable to recognize ‘/mnt/disk1/data/soft/hadoop-2.5.2’ as a valid HADOOP
installation folder. Check that this is the root of your HADOOP installation
folder.
Thanks and Best Wishes.
Xinsong hadoop, parallel computing tool, hadoop_home, linux MATLAB Answers — New Questions
uigetfile Multiselect option not working for single file select
I have been trying to figure out why you can’t select a single file, if you have the ‘MultiSelect’ option set to ‘on’ in the uigetfile command. I need to be able to select ‘one or more’ files. Here is the code:
% Select and Open file
[files, pathname] = uigetfile({‘*.xls*’; ‘*.csv’}, …
‘Select One or More Files’, ‘MultiSelect’, ‘on’);
for filecount = 1:length(files)
filename = convertCharsToStrings(files(filecount));
opts = detectImportOptions(filename, VariableNamingRule="modify");
MDRdata = readtable(filename, opts);
time = datetime(MDRdata.ZuluDate_Time,"InputFormat",’yyyy-MM-dd”T”HH:mm:ss.SSS”Z’);
time.Format = ‘HH:mm:ss.SSS’;
….
I keep getting the following:
"Error using detectImportOptions
Unable to find or open ‘1’. Check the path and filename or file permissions.
Error in ApacheMDRProgram_04162024 (line 12)
opts = detectImportOptions(filename, VariableNamingRule="modify");"
It works fine if you select more than one file.I have been trying to figure out why you can’t select a single file, if you have the ‘MultiSelect’ option set to ‘on’ in the uigetfile command. I need to be able to select ‘one or more’ files. Here is the code:
% Select and Open file
[files, pathname] = uigetfile({‘*.xls*’; ‘*.csv’}, …
‘Select One or More Files’, ‘MultiSelect’, ‘on’);
for filecount = 1:length(files)
filename = convertCharsToStrings(files(filecount));
opts = detectImportOptions(filename, VariableNamingRule="modify");
MDRdata = readtable(filename, opts);
time = datetime(MDRdata.ZuluDate_Time,"InputFormat",’yyyy-MM-dd”T”HH:mm:ss.SSS”Z’);
time.Format = ‘HH:mm:ss.SSS’;
….
I keep getting the following:
"Error using detectImportOptions
Unable to find or open ‘1’. Check the path and filename or file permissions.
Error in ApacheMDRProgram_04162024 (line 12)
opts = detectImportOptions(filename, VariableNamingRule="modify");"
It works fine if you select more than one file. I have been trying to figure out why you can’t select a single file, if you have the ‘MultiSelect’ option set to ‘on’ in the uigetfile command. I need to be able to select ‘one or more’ files. Here is the code:
% Select and Open file
[files, pathname] = uigetfile({‘*.xls*’; ‘*.csv’}, …
‘Select One or More Files’, ‘MultiSelect’, ‘on’);
for filecount = 1:length(files)
filename = convertCharsToStrings(files(filecount));
opts = detectImportOptions(filename, VariableNamingRule="modify");
MDRdata = readtable(filename, opts);
time = datetime(MDRdata.ZuluDate_Time,"InputFormat",’yyyy-MM-dd”T”HH:mm:ss.SSS”Z’);
time.Format = ‘HH:mm:ss.SSS’;
….
I keep getting the following:
"Error using detectImportOptions
Unable to find or open ‘1’. Check the path and filename or file permissions.
Error in ApacheMDRProgram_04162024 (line 12)
opts = detectImportOptions(filename, VariableNamingRule="modify");"
It works fine if you select more than one file. transferred MATLAB Answers — New Questions
Unable to perform assignment because the size of the left side is 1-by-1 and the size of the right side is 1-by-15. – can’t find what the problem is
I keep getting this error, but I have no idea what’s causing it.
Using the step button brings up nothing until the very end when it tries to finish.
all of the X’s,Z’s,Y’s within Fd are 15×1 with positive integers
Any ideas as to what’s causing this?
Fd=zeros(cap, cap, cap,term); %here is the original matrix I created cap=15 and term=20
…
for tt=19:-1:1
for i=1:cap
for j=1:cap
for k=1:cap
… %for brevity’s sake I’ve ommitted some stuff here that doesn’t seem to be causing issues
Fd(i,j,k,tt)= b*(…
m1*(…
p(y(j),z1(k))*(n1*Fd(xp(i),zp(j),y(k),tt+1) + (1-n1)*Fd(xpp(i),zpp(j),y(k),tt+1))+…
(1-p(y(j),z1(k)))*(n2*Fd(xp(i),z1(j),yg(k),tt+1) + (1-n2)*Fd(xpp(i),z1(j),ygg(k),tt+1)))+…
(1-m1)*(…
p2(y(j),z2(k))*(n1*Fd(xp(i),zd(j),y(k),tt+1) + (1-n1)*Fd(xpp(i),zdd(j),y(k),tt+1))+…
(1-p2(y(j),z2(k)))*(n2*Fd(xp(i),z2(j),yg(k),tt+1) + (1-n2)*Fd(xpp(i),z2(j),ygg(k),tt+1))…
))+…
(1-b)*( …
m2*(…
p(y1(j),z(k))*(n1*Fd(xp(i),zg(j),y1(k),tt+1) + (1-n1)*Fd(xpp(i) ,zgg(j),y1(k),tt+1))+ …
(1-p(y1(j),z(k)))*(n2*Fd(xp(i),z(j),yp(k),tt+1) + (1-n2)*Fd(xpp(i) ,z(j),ypp(k),tt+1)))+ …
(1-m2)*(p(y2(j),z(k))*(n1*Fd(xp(i),zg(j),y2(k),tt+1) + (1-n1)*Fd(xpp(i),zgg(j),y2(k),tt+1))+…
(1-p(y2(j),z(k)))*(n2*Fd(xp(i),z(j),yd(k),tt+1) + (1-n2)*Fd(xpp(i),z(j),ydd(k),tt+1))));
If more code is required, I can certainly provideI keep getting this error, but I have no idea what’s causing it.
Using the step button brings up nothing until the very end when it tries to finish.
all of the X’s,Z’s,Y’s within Fd are 15×1 with positive integers
Any ideas as to what’s causing this?
Fd=zeros(cap, cap, cap,term); %here is the original matrix I created cap=15 and term=20
…
for tt=19:-1:1
for i=1:cap
for j=1:cap
for k=1:cap
… %for brevity’s sake I’ve ommitted some stuff here that doesn’t seem to be causing issues
Fd(i,j,k,tt)= b*(…
m1*(…
p(y(j),z1(k))*(n1*Fd(xp(i),zp(j),y(k),tt+1) + (1-n1)*Fd(xpp(i),zpp(j),y(k),tt+1))+…
(1-p(y(j),z1(k)))*(n2*Fd(xp(i),z1(j),yg(k),tt+1) + (1-n2)*Fd(xpp(i),z1(j),ygg(k),tt+1)))+…
(1-m1)*(…
p2(y(j),z2(k))*(n1*Fd(xp(i),zd(j),y(k),tt+1) + (1-n1)*Fd(xpp(i),zdd(j),y(k),tt+1))+…
(1-p2(y(j),z2(k)))*(n2*Fd(xp(i),z2(j),yg(k),tt+1) + (1-n2)*Fd(xpp(i),z2(j),ygg(k),tt+1))…
))+…
(1-b)*( …
m2*(…
p(y1(j),z(k))*(n1*Fd(xp(i),zg(j),y1(k),tt+1) + (1-n1)*Fd(xpp(i) ,zgg(j),y1(k),tt+1))+ …
(1-p(y1(j),z(k)))*(n2*Fd(xp(i),z(j),yp(k),tt+1) + (1-n2)*Fd(xpp(i) ,z(j),ypp(k),tt+1)))+ …
(1-m2)*(p(y2(j),z(k))*(n1*Fd(xp(i),zg(j),y2(k),tt+1) + (1-n1)*Fd(xpp(i),zgg(j),y2(k),tt+1))+…
(1-p(y2(j),z(k)))*(n2*Fd(xp(i),z(j),yd(k),tt+1) + (1-n2)*Fd(xpp(i),z(j),ydd(k),tt+1))));
If more code is required, I can certainly provide I keep getting this error, but I have no idea what’s causing it.
Using the step button brings up nothing until the very end when it tries to finish.
all of the X’s,Z’s,Y’s within Fd are 15×1 with positive integers
Any ideas as to what’s causing this?
Fd=zeros(cap, cap, cap,term); %here is the original matrix I created cap=15 and term=20
…
for tt=19:-1:1
for i=1:cap
for j=1:cap
for k=1:cap
… %for brevity’s sake I’ve ommitted some stuff here that doesn’t seem to be causing issues
Fd(i,j,k,tt)= b*(…
m1*(…
p(y(j),z1(k))*(n1*Fd(xp(i),zp(j),y(k),tt+1) + (1-n1)*Fd(xpp(i),zpp(j),y(k),tt+1))+…
(1-p(y(j),z1(k)))*(n2*Fd(xp(i),z1(j),yg(k),tt+1) + (1-n2)*Fd(xpp(i),z1(j),ygg(k),tt+1)))+…
(1-m1)*(…
p2(y(j),z2(k))*(n1*Fd(xp(i),zd(j),y(k),tt+1) + (1-n1)*Fd(xpp(i),zdd(j),y(k),tt+1))+…
(1-p2(y(j),z2(k)))*(n2*Fd(xp(i),z2(j),yg(k),tt+1) + (1-n2)*Fd(xpp(i),z2(j),ygg(k),tt+1))…
))+…
(1-b)*( …
m2*(…
p(y1(j),z(k))*(n1*Fd(xp(i),zg(j),y1(k),tt+1) + (1-n1)*Fd(xpp(i) ,zgg(j),y1(k),tt+1))+ …
(1-p(y1(j),z(k)))*(n2*Fd(xp(i),z(j),yp(k),tt+1) + (1-n2)*Fd(xpp(i) ,z(j),ypp(k),tt+1)))+ …
(1-m2)*(p(y2(j),z(k))*(n1*Fd(xp(i),zg(j),y2(k),tt+1) + (1-n1)*Fd(xpp(i),zgg(j),y2(k),tt+1))+…
(1-p(y2(j),z(k)))*(n2*Fd(xp(i),z(j),yd(k),tt+1) + (1-n2)*Fd(xpp(i),z(j),ydd(k),tt+1))));
If more code is required, I can certainly provide matrix array MATLAB Answers — New Questions
copy subplots within same figure
I am copying subplots within a figure, to show the same data with an expaned time base.
As you can see from the example below, the copied subplots overlap somewhat, and the legends do not get copied. Is there a better way to do this?
t=(0:200)’;
x=[cos(t),sin(t),cos(t/2),sin(t/2),cos(t/4),sin(t/4)];
fig1=figure(1);
ax1(1,1)=subplot(321);
plot(t,x(:,1),’-r’,t,x(:,2),’-g’);
xlabel(‘Time’); ylabel(‘XA’); title(‘A’); legend({‘cos’,’sin’})
ax1(2,1)=subplot(323);
plot(t,x(:,3),’-b’,t,x(:,4),’-c’);
xlabel(‘Time’); ylabel(‘XB’); title(‘B’); legend({‘cos’,’sin’})
ax1(3,1)=subplot(325);
plot(t,x(:,5),’-m’,t,x(:,6),’-y’);
xlabel(‘Time’); ylabel(‘XC’); title(‘C’); legend({‘cos’,’sin’})
% Next: Copy column 1 plots to column 2, and adjust axes.
for i=1:3
axtemp=subplot(3,2,2*i);
ax1(i,2)=copyobj(ax1(i,1),fig1);
ax1(i,2).Position=axtemp.Position;
delete(axtemp)
xlim([0,20])
end
Thank you.I am copying subplots within a figure, to show the same data with an expaned time base.
As you can see from the example below, the copied subplots overlap somewhat, and the legends do not get copied. Is there a better way to do this?
t=(0:200)’;
x=[cos(t),sin(t),cos(t/2),sin(t/2),cos(t/4),sin(t/4)];
fig1=figure(1);
ax1(1,1)=subplot(321);
plot(t,x(:,1),’-r’,t,x(:,2),’-g’);
xlabel(‘Time’); ylabel(‘XA’); title(‘A’); legend({‘cos’,’sin’})
ax1(2,1)=subplot(323);
plot(t,x(:,3),’-b’,t,x(:,4),’-c’);
xlabel(‘Time’); ylabel(‘XB’); title(‘B’); legend({‘cos’,’sin’})
ax1(3,1)=subplot(325);
plot(t,x(:,5),’-m’,t,x(:,6),’-y’);
xlabel(‘Time’); ylabel(‘XC’); title(‘C’); legend({‘cos’,’sin’})
% Next: Copy column 1 plots to column 2, and adjust axes.
for i=1:3
axtemp=subplot(3,2,2*i);
ax1(i,2)=copyobj(ax1(i,1),fig1);
ax1(i,2).Position=axtemp.Position;
delete(axtemp)
xlim([0,20])
end
Thank you. I am copying subplots within a figure, to show the same data with an expaned time base.
As you can see from the example below, the copied subplots overlap somewhat, and the legends do not get copied. Is there a better way to do this?
t=(0:200)’;
x=[cos(t),sin(t),cos(t/2),sin(t/2),cos(t/4),sin(t/4)];
fig1=figure(1);
ax1(1,1)=subplot(321);
plot(t,x(:,1),’-r’,t,x(:,2),’-g’);
xlabel(‘Time’); ylabel(‘XA’); title(‘A’); legend({‘cos’,’sin’})
ax1(2,1)=subplot(323);
plot(t,x(:,3),’-b’,t,x(:,4),’-c’);
xlabel(‘Time’); ylabel(‘XB’); title(‘B’); legend({‘cos’,’sin’})
ax1(3,1)=subplot(325);
plot(t,x(:,5),’-m’,t,x(:,6),’-y’);
xlabel(‘Time’); ylabel(‘XC’); title(‘C’); legend({‘cos’,’sin’})
% Next: Copy column 1 plots to column 2, and adjust axes.
for i=1:3
axtemp=subplot(3,2,2*i);
ax1(i,2)=copyobj(ax1(i,1),fig1);
ax1(i,2).Position=axtemp.Position;
delete(axtemp)
xlim([0,20])
end
Thank you. subplot copyobj MATLAB Answers — New Questions
How to detect (programmatically induced) value changes of uidropdown?
Situation:
I am currently creating a UI with some dropdown menus that are dynamically populated (based on hardware devices that are connected to the PC). I might change the selectable items and the value programmatically without a user action required.
I want to trigger the execution of a function on the change of the value of the dropdown menu.
I am aware of the ValueChangedFcn callback. However this callback is only executed when the change is made by the user via the UI and not by programmatically induced changes to the value, as one can read in the documentation (This callback function executes when the user selects a different option from the drop-down list. It does not execute if the Value property changes programmatically).
What does not work:
Typically I would add an event listener but the property Value is not SetObservable so this does not work.
Subclassing the class to register a custom set method is also not possible cause uidropdown is sealed.
In my case I always know when I change the value programatically and I could trigger the desired function manually but this does not seem right to me because I then need use the ValueChngedFcn for user changes, add the function every time I change the value and/or write a custom function that changes the value and then automatically executes the function.
All of that seems not right because I would really like to bind the triggering of the function to the change of the value itself and not the cause of it.
Am I misusing uidropdown?
Do I misuse the dropdown menu to store a value and should rather have a separate variable for it that will be changed when the user makes a selection in the dropdown menu?
When using a separate variable I need to take special care to properly initalize that variable and the dropdown menu so that it reflects the value in the dropdown manu at all times.
>> What are your ideas to solve this problem in an elegant way?Situation:
I am currently creating a UI with some dropdown menus that are dynamically populated (based on hardware devices that are connected to the PC). I might change the selectable items and the value programmatically without a user action required.
I want to trigger the execution of a function on the change of the value of the dropdown menu.
I am aware of the ValueChangedFcn callback. However this callback is only executed when the change is made by the user via the UI and not by programmatically induced changes to the value, as one can read in the documentation (This callback function executes when the user selects a different option from the drop-down list. It does not execute if the Value property changes programmatically).
What does not work:
Typically I would add an event listener but the property Value is not SetObservable so this does not work.
Subclassing the class to register a custom set method is also not possible cause uidropdown is sealed.
In my case I always know when I change the value programatically and I could trigger the desired function manually but this does not seem right to me because I then need use the ValueChngedFcn for user changes, add the function every time I change the value and/or write a custom function that changes the value and then automatically executes the function.
All of that seems not right because I would really like to bind the triggering of the function to the change of the value itself and not the cause of it.
Am I misusing uidropdown?
Do I misuse the dropdown menu to store a value and should rather have a separate variable for it that will be changed when the user makes a selection in the dropdown menu?
When using a separate variable I need to take special care to properly initalize that variable and the dropdown menu so that it reflects the value in the dropdown manu at all times.
>> What are your ideas to solve this problem in an elegant way? Situation:
I am currently creating a UI with some dropdown menus that are dynamically populated (based on hardware devices that are connected to the PC). I might change the selectable items and the value programmatically without a user action required.
I want to trigger the execution of a function on the change of the value of the dropdown menu.
I am aware of the ValueChangedFcn callback. However this callback is only executed when the change is made by the user via the UI and not by programmatically induced changes to the value, as one can read in the documentation (This callback function executes when the user selects a different option from the drop-down list. It does not execute if the Value property changes programmatically).
What does not work:
Typically I would add an event listener but the property Value is not SetObservable so this does not work.
Subclassing the class to register a custom set method is also not possible cause uidropdown is sealed.
In my case I always know when I change the value programatically and I could trigger the desired function manually but this does not seem right to me because I then need use the ValueChngedFcn for user changes, add the function every time I change the value and/or write a custom function that changes the value and then automatically executes the function.
All of that seems not right because I would really like to bind the triggering of the function to the change of the value itself and not the cause of it.
Am I misusing uidropdown?
Do I misuse the dropdown menu to store a value and should rather have a separate variable for it that will be changed when the user makes a selection in the dropdown menu?
When using a separate variable I need to take special care to properly initalize that variable and the dropdown menu so that it reflects the value in the dropdown manu at all times.
>> What are your ideas to solve this problem in an elegant way? app designer, callback, uidropdown MATLAB Answers — New Questions
New Desktop for MATLAB not working on Ubuntu (Wayland)
On Linux Ubuntu, when I switch to using the New Desktop for MATLAB, I can’t type in the command window or inside a script, and I cannot change any settings in the prefferences window. I wanted to use the dark theme, but the dropdown menus are not functional – if I select something in a dropdown menu, it just closes without updating.
On Ubuntu login, there’s a cogwheel in the bottom right to choose if I wanna start my session using Ubuntu (on Wayland, default) or Ubuntu on Xorg. Wayland is the default windowing system that I’ve been using ever since, but once I tried with Xorg, New Desktop for MATLAB worked as expected. However, I don’t wanna keep using Xorg since a lot of Ubuntu options that I had set in Wayland don’t stick (examples are natural scrolling, disable touchpad while typing, three-finger middle-click). I managed to change the theme in Xorg and switch back to Wayland and the dark theme stayed, but other issues still persist.
Is this a known issue?
More importantly, is there a way to make New Desktop for MATLAB work on default Ubuntu (Wayland), or do I have to use Ubuntu on Xorg?
Version: Ubuntu 22.04.4 LTSOn Linux Ubuntu, when I switch to using the New Desktop for MATLAB, I can’t type in the command window or inside a script, and I cannot change any settings in the prefferences window. I wanted to use the dark theme, but the dropdown menus are not functional – if I select something in a dropdown menu, it just closes without updating.
On Ubuntu login, there’s a cogwheel in the bottom right to choose if I wanna start my session using Ubuntu (on Wayland, default) or Ubuntu on Xorg. Wayland is the default windowing system that I’ve been using ever since, but once I tried with Xorg, New Desktop for MATLAB worked as expected. However, I don’t wanna keep using Xorg since a lot of Ubuntu options that I had set in Wayland don’t stick (examples are natural scrolling, disable touchpad while typing, three-finger middle-click). I managed to change the theme in Xorg and switch back to Wayland and the dark theme stayed, but other issues still persist.
Is this a known issue?
More importantly, is there a way to make New Desktop for MATLAB work on default Ubuntu (Wayland), or do I have to use Ubuntu on Xorg?
Version: Ubuntu 22.04.4 LTS On Linux Ubuntu, when I switch to using the New Desktop for MATLAB, I can’t type in the command window or inside a script, and I cannot change any settings in the prefferences window. I wanted to use the dark theme, but the dropdown menus are not functional – if I select something in a dropdown menu, it just closes without updating.
On Ubuntu login, there’s a cogwheel in the bottom right to choose if I wanna start my session using Ubuntu (on Wayland, default) or Ubuntu on Xorg. Wayland is the default windowing system that I’ve been using ever since, but once I tried with Xorg, New Desktop for MATLAB worked as expected. However, I don’t wanna keep using Xorg since a lot of Ubuntu options that I had set in Wayland don’t stick (examples are natural scrolling, disable touchpad while typing, three-finger middle-click). I managed to change the theme in Xorg and switch back to Wayland and the dark theme stayed, but other issues still persist.
Is this a known issue?
More importantly, is there a way to make New Desktop for MATLAB work on default Ubuntu (Wayland), or do I have to use Ubuntu on Xorg?
Version: Ubuntu 22.04.4 LTS linux, ubuntu MATLAB Answers — New Questions