Category: Matlab
Category Archives: Matlab
stepper motor control
hi to all,
i am currently doing a project on robotic arm. i have successfully connect and run my motor through serial port. but now i need to control the robotic arm to move to a desired position..can someone give me any idea on how to do that??..do i need to control the speed as well??
thanks a lot in advancehi to all,
i am currently doing a project on robotic arm. i have successfully connect and run my motor through serial port. but now i need to control the robotic arm to move to a desired position..can someone give me any idea on how to do that??..do i need to control the speed as well??
thanks a lot in advance hi to all,
i am currently doing a project on robotic arm. i have successfully connect and run my motor through serial port. but now i need to control the robotic arm to move to a desired position..can someone give me any idea on how to do that??..do i need to control the speed as well??
thanks a lot in advance gui, robot, power_electronics_control, electric_motor_control MATLAB Answers — New Questions
the folder AMSimulink.ml not available
After installation of MATLAB i can use connection of MATLAB and Aspentech dynamic
after that not possible due to AMSimulink.ml not availbleAfter installation of MATLAB i can use connection of MATLAB and Aspentech dynamic
after that not possible due to AMSimulink.ml not availble After installation of MATLAB i can use connection of MATLAB and Aspentech dynamic
after that not possible due to AMSimulink.ml not availble amsimulink.ml and matlab aspentch not installed MATLAB Answers — New Questions
Pressure-flow characteristic for a 4-Way Directional Valve
I’ve to parametrize the block "4-Way Directional Valve" in Simscape Fluids by using Pressure-flow characteristic. I’ve read carefully the documentation: https://it.mathworks.com/help/physmod/hydro/ref/4waydirectionalvalve.html, but unfortunately not everything is clear. In particular the pressure differential vector is not well defined (what positive pressure or negative pressure means?) and the same for the volumetric flow. Assuming positive pressure drop from A to P and positive flow from P to A I’ve used the following parameter, but I’m note sure it’s right, someone could confirm?
x= [0,2,4,6,8,10]; %mm, spool position
P=[5,50,315]; %pressure vector bar
q5b= [0,0, 4, 14,31,58]; %liters/minute at 5 bar
q50b=[0,0, 8, 20,35,58]; %liters/minute at 50 bar
q315b=[0,0, 13, 23,33,40]; %liters/minute at 315 bar
M=[q5b’ q50b’ q315b’]; %volumetric flow rate tableI’ve to parametrize the block "4-Way Directional Valve" in Simscape Fluids by using Pressure-flow characteristic. I’ve read carefully the documentation: https://it.mathworks.com/help/physmod/hydro/ref/4waydirectionalvalve.html, but unfortunately not everything is clear. In particular the pressure differential vector is not well defined (what positive pressure or negative pressure means?) and the same for the volumetric flow. Assuming positive pressure drop from A to P and positive flow from P to A I’ve used the following parameter, but I’m note sure it’s right, someone could confirm?
x= [0,2,4,6,8,10]; %mm, spool position
P=[5,50,315]; %pressure vector bar
q5b= [0,0, 4, 14,31,58]; %liters/minute at 5 bar
q50b=[0,0, 8, 20,35,58]; %liters/minute at 50 bar
q315b=[0,0, 13, 23,33,40]; %liters/minute at 315 bar
M=[q5b’ q50b’ q315b’]; %volumetric flow rate table I’ve to parametrize the block "4-Way Directional Valve" in Simscape Fluids by using Pressure-flow characteristic. I’ve read carefully the documentation: https://it.mathworks.com/help/physmod/hydro/ref/4waydirectionalvalve.html, but unfortunately not everything is clear. In particular the pressure differential vector is not well defined (what positive pressure or negative pressure means?) and the same for the volumetric flow. Assuming positive pressure drop from A to P and positive flow from P to A I’ve used the following parameter, but I’m note sure it’s right, someone could confirm?
x= [0,2,4,6,8,10]; %mm, spool position
P=[5,50,315]; %pressure vector bar
q5b= [0,0, 4, 14,31,58]; %liters/minute at 5 bar
q50b=[0,0, 8, 20,35,58]; %liters/minute at 50 bar
q315b=[0,0, 13, 23,33,40]; %liters/minute at 315 bar
M=[q5b’ q50b’ q315b’]; %volumetric flow rate table 4-way directional valve MATLAB Answers — New Questions
reinforcement learning toolbox. error: Error encountered while creating actor representation: Observation names must match the names of the deep neural network’s input layers.
Error encountered while creating actor representation:
Observation names must match the names of the deep neural network’s input layers. Make sure all observation names appear in the neural network.
My code
% Clear workspace, command window, and close all figures
clear all; clc; close all;
% Define State and Action Dimensions
stateDim = 5; % State dimension
actionDim = 3; % Action dimension
% Create Observation and Action Specifications
ObservationInfo = rlNumericSpec([stateDim 1]);
ObservationInfo.Name = "state";
ActionInfo = rlNumericSpec([actionDim 1], ‘LowerLimit’, [-1; -1; -1], ‘UpperLimit’, [1; 1; 1]);
ActionInfo.Name = "action";
% Display the properties to ensure consistency
disp(ObservationInfo);
disp(ActionInfo);
% Create the environment with the step and reset functions
try
env = rlFunctionEnv(ObservationInfo, ActionInfo, @stepFunction, @resetFunction);
catch ME
disp(‘Error setting up environment:’);
disp(ME.message);
return;
end
% Create a minimal critic network
criticNetwork = [
featureInputLayer(stateDim, ‘Normalization’, ‘none’, ‘Name’, ‘state’)
fullyConnectedLayer(1, ‘Name’, ‘output’)];
% Create a minimal actor network
actorNetwork = [
featureInputLayer(stateDim, ‘Normalization’, ‘none’, ‘Name’, ‘state’)
fullyConnectedLayer(actionDim, ‘Name’, ‘output’)];
% Display layer names for verification
disp([‘Critic Network Input Layer Name: ‘, criticNetwork(1).Name]);
disp([‘Actor Network Input Layer Name: ‘, actorNetwork(1).Name]);
% Attempt to create the actor and critic representations
try
critic = rlValueFunction(layerGraph(criticNetwork), ObservationInfo);
actor = rlStochasticActorRepresentation(layerGraph(actorNetwork), ObservationInfo, ActionInfo);
catch ME
disp(‘Error encountered while creating actor representation:’);
disp(ME.message);
disp(‘Observation Info and Actor Network Input Layer Names:’);
disp([‘ObservationInfo Name: ‘, ObservationInfo.Name]);
disp([‘Actor Network Input Layer Name: ‘, actorNetwork(1).Name]);
return; % Stop execution if there’s a mismatch error
end
% Create the PPO agent and specify agent options
agentOptions = rlPPOAgentOptions(‘ClipFactor’, 0.2, ‘EntropyLossWeight’, 0.01, …
‘SampleTime’, 0.1, ‘MiniBatchSize’, 64, ‘ExperienceHorizon’, 128);
agent = rlPPOAgent(actor, critic, agentOptions);
% Specify training options and run training
trainOpts = rlTrainingOptions(‘MaxEpisodes’, 1000, ‘MaxStepsPerEpisode’, 500, …
‘Verbose’, true, ‘Plots’, ‘training-progress’, ‘StopTrainingCriteria’, ‘AverageReward’, …
‘StopTrainingValue’, 500);
trainingStats = train(agent, env, trainOpts);
% Custom reset function to initialize the environment
function [initialObs, loggedSignals] = resetFunction()
stateDim = 5;
initialObs = randn(stateDim, 1);
loggedSignals.State = initialObs;
end
% Custom step function to define environment behavior
function [nextObs, reward, isDone, loggedSignals] = stepFunction(action, loggedSignals)
state = loggedSignals.State;
nextObs = state + [0.1 * action; zeros(2, 1)];
reward = -sum((nextObs(1:3) – action).^2);
isDone = any(abs(nextObs(1:3)) > 10);
loggedSignals.State = nextObs;
endError encountered while creating actor representation:
Observation names must match the names of the deep neural network’s input layers. Make sure all observation names appear in the neural network.
My code
% Clear workspace, command window, and close all figures
clear all; clc; close all;
% Define State and Action Dimensions
stateDim = 5; % State dimension
actionDim = 3; % Action dimension
% Create Observation and Action Specifications
ObservationInfo = rlNumericSpec([stateDim 1]);
ObservationInfo.Name = "state";
ActionInfo = rlNumericSpec([actionDim 1], ‘LowerLimit’, [-1; -1; -1], ‘UpperLimit’, [1; 1; 1]);
ActionInfo.Name = "action";
% Display the properties to ensure consistency
disp(ObservationInfo);
disp(ActionInfo);
% Create the environment with the step and reset functions
try
env = rlFunctionEnv(ObservationInfo, ActionInfo, @stepFunction, @resetFunction);
catch ME
disp(‘Error setting up environment:’);
disp(ME.message);
return;
end
% Create a minimal critic network
criticNetwork = [
featureInputLayer(stateDim, ‘Normalization’, ‘none’, ‘Name’, ‘state’)
fullyConnectedLayer(1, ‘Name’, ‘output’)];
% Create a minimal actor network
actorNetwork = [
featureInputLayer(stateDim, ‘Normalization’, ‘none’, ‘Name’, ‘state’)
fullyConnectedLayer(actionDim, ‘Name’, ‘output’)];
% Display layer names for verification
disp([‘Critic Network Input Layer Name: ‘, criticNetwork(1).Name]);
disp([‘Actor Network Input Layer Name: ‘, actorNetwork(1).Name]);
% Attempt to create the actor and critic representations
try
critic = rlValueFunction(layerGraph(criticNetwork), ObservationInfo);
actor = rlStochasticActorRepresentation(layerGraph(actorNetwork), ObservationInfo, ActionInfo);
catch ME
disp(‘Error encountered while creating actor representation:’);
disp(ME.message);
disp(‘Observation Info and Actor Network Input Layer Names:’);
disp([‘ObservationInfo Name: ‘, ObservationInfo.Name]);
disp([‘Actor Network Input Layer Name: ‘, actorNetwork(1).Name]);
return; % Stop execution if there’s a mismatch error
end
% Create the PPO agent and specify agent options
agentOptions = rlPPOAgentOptions(‘ClipFactor’, 0.2, ‘EntropyLossWeight’, 0.01, …
‘SampleTime’, 0.1, ‘MiniBatchSize’, 64, ‘ExperienceHorizon’, 128);
agent = rlPPOAgent(actor, critic, agentOptions);
% Specify training options and run training
trainOpts = rlTrainingOptions(‘MaxEpisodes’, 1000, ‘MaxStepsPerEpisode’, 500, …
‘Verbose’, true, ‘Plots’, ‘training-progress’, ‘StopTrainingCriteria’, ‘AverageReward’, …
‘StopTrainingValue’, 500);
trainingStats = train(agent, env, trainOpts);
% Custom reset function to initialize the environment
function [initialObs, loggedSignals] = resetFunction()
stateDim = 5;
initialObs = randn(stateDim, 1);
loggedSignals.State = initialObs;
end
% Custom step function to define environment behavior
function [nextObs, reward, isDone, loggedSignals] = stepFunction(action, loggedSignals)
state = loggedSignals.State;
nextObs = state + [0.1 * action; zeros(2, 1)];
reward = -sum((nextObs(1:3) – action).^2);
isDone = any(abs(nextObs(1:3)) > 10);
loggedSignals.State = nextObs;
end Error encountered while creating actor representation:
Observation names must match the names of the deep neural network’s input layers. Make sure all observation names appear in the neural network.
My code
% Clear workspace, command window, and close all figures
clear all; clc; close all;
% Define State and Action Dimensions
stateDim = 5; % State dimension
actionDim = 3; % Action dimension
% Create Observation and Action Specifications
ObservationInfo = rlNumericSpec([stateDim 1]);
ObservationInfo.Name = "state";
ActionInfo = rlNumericSpec([actionDim 1], ‘LowerLimit’, [-1; -1; -1], ‘UpperLimit’, [1; 1; 1]);
ActionInfo.Name = "action";
% Display the properties to ensure consistency
disp(ObservationInfo);
disp(ActionInfo);
% Create the environment with the step and reset functions
try
env = rlFunctionEnv(ObservationInfo, ActionInfo, @stepFunction, @resetFunction);
catch ME
disp(‘Error setting up environment:’);
disp(ME.message);
return;
end
% Create a minimal critic network
criticNetwork = [
featureInputLayer(stateDim, ‘Normalization’, ‘none’, ‘Name’, ‘state’)
fullyConnectedLayer(1, ‘Name’, ‘output’)];
% Create a minimal actor network
actorNetwork = [
featureInputLayer(stateDim, ‘Normalization’, ‘none’, ‘Name’, ‘state’)
fullyConnectedLayer(actionDim, ‘Name’, ‘output’)];
% Display layer names for verification
disp([‘Critic Network Input Layer Name: ‘, criticNetwork(1).Name]);
disp([‘Actor Network Input Layer Name: ‘, actorNetwork(1).Name]);
% Attempt to create the actor and critic representations
try
critic = rlValueFunction(layerGraph(criticNetwork), ObservationInfo);
actor = rlStochasticActorRepresentation(layerGraph(actorNetwork), ObservationInfo, ActionInfo);
catch ME
disp(‘Error encountered while creating actor representation:’);
disp(ME.message);
disp(‘Observation Info and Actor Network Input Layer Names:’);
disp([‘ObservationInfo Name: ‘, ObservationInfo.Name]);
disp([‘Actor Network Input Layer Name: ‘, actorNetwork(1).Name]);
return; % Stop execution if there’s a mismatch error
end
% Create the PPO agent and specify agent options
agentOptions = rlPPOAgentOptions(‘ClipFactor’, 0.2, ‘EntropyLossWeight’, 0.01, …
‘SampleTime’, 0.1, ‘MiniBatchSize’, 64, ‘ExperienceHorizon’, 128);
agent = rlPPOAgent(actor, critic, agentOptions);
% Specify training options and run training
trainOpts = rlTrainingOptions(‘MaxEpisodes’, 1000, ‘MaxStepsPerEpisode’, 500, …
‘Verbose’, true, ‘Plots’, ‘training-progress’, ‘StopTrainingCriteria’, ‘AverageReward’, …
‘StopTrainingValue’, 500);
trainingStats = train(agent, env, trainOpts);
% Custom reset function to initialize the environment
function [initialObs, loggedSignals] = resetFunction()
stateDim = 5;
initialObs = randn(stateDim, 1);
loggedSignals.State = initialObs;
end
% Custom step function to define environment behavior
function [nextObs, reward, isDone, loggedSignals] = stepFunction(action, loggedSignals)
state = loggedSignals.State;
nextObs = state + [0.1 * action; zeros(2, 1)];
reward = -sum((nextObs(1:3) – action).^2);
isDone = any(abs(nextObs(1:3)) > 10);
loggedSignals.State = nextObs;
end reinforced learning, observation names, deep neural network’s input layers. MATLAB Answers — New Questions
What types of components should be connected to the interfaces of the fault(three-phase) module?
What components should be connected to the external trigger of the faulty (three-phase) module? I think it should be input control signals, such as step modules, PWM modules, or signal generators. But the interface of the faulty module is triangular, and none of the above matches and cannot be connected. Should I choose other modules? How do I still need to convert it? Another interface is the three-phase composite interface, which directly includes the ABC three-phase, which makes it impossible for me to connect this faulty module to my three-phase circuit. Even if I tried to combine the three phases with mux, I couldn’t connect to the symbol interface. Can this interface only connect components such as programmable voltage sources that are also three-phase composite interfaces?What components should be connected to the external trigger of the faulty (three-phase) module? I think it should be input control signals, such as step modules, PWM modules, or signal generators. But the interface of the faulty module is triangular, and none of the above matches and cannot be connected. Should I choose other modules? How do I still need to convert it? Another interface is the three-phase composite interface, which directly includes the ABC three-phase, which makes it impossible for me to connect this faulty module to my three-phase circuit. Even if I tried to combine the three phases with mux, I couldn’t connect to the symbol interface. Can this interface only connect components such as programmable voltage sources that are also three-phase composite interfaces? What components should be connected to the external trigger of the faulty (three-phase) module? I think it should be input control signals, such as step modules, PWM modules, or signal generators. But the interface of the faulty module is triangular, and none of the above matches and cannot be connected. Should I choose other modules? How do I still need to convert it? Another interface is the three-phase composite interface, which directly includes the ABC three-phase, which makes it impossible for me to connect this faulty module to my three-phase circuit. Even if I tried to combine the three phases with mux, I couldn’t connect to the symbol interface. Can this interface only connect components such as programmable voltage sources that are also three-phase composite interfaces? simulink, signal MATLAB Answers — New Questions
Multiply two probability plots (CDF/PDF)
I have two probability plots, one generated as a CDF, and one as a pdf. The exact mathematics is not important for my purpose, I only want to extract the qualitative idea.
This is the code I used:
figure()
ax1 = subplot(1,1,1);
cdfplot(temp);
% plot(DE,y)
ax1.XDir = ‘reverse’;
set(gca, ‘YScale’, ‘log’)
figure();
pd_HOLT = fitdist(total_HOLT,’Normal’);
DE_HOLT = bingroups_HOLT;
y_HOLT = pdf(pd_HOLT,DE_HOLT);
ax1 = subplot(1,1,1);
plot(DE_HOLT,y_HOLT)
ax1.XDir = ‘reverse’;
set(gca, ‘YScale’, ‘log’)
The x-axis is the same. How can I multiply these plots to convey a (qualitative) idea? Thanks.I have two probability plots, one generated as a CDF, and one as a pdf. The exact mathematics is not important for my purpose, I only want to extract the qualitative idea.
This is the code I used:
figure()
ax1 = subplot(1,1,1);
cdfplot(temp);
% plot(DE,y)
ax1.XDir = ‘reverse’;
set(gca, ‘YScale’, ‘log’)
figure();
pd_HOLT = fitdist(total_HOLT,’Normal’);
DE_HOLT = bingroups_HOLT;
y_HOLT = pdf(pd_HOLT,DE_HOLT);
ax1 = subplot(1,1,1);
plot(DE_HOLT,y_HOLT)
ax1.XDir = ‘reverse’;
set(gca, ‘YScale’, ‘log’)
The x-axis is the same. How can I multiply these plots to convey a (qualitative) idea? Thanks. I have two probability plots, one generated as a CDF, and one as a pdf. The exact mathematics is not important for my purpose, I only want to extract the qualitative idea.
This is the code I used:
figure()
ax1 = subplot(1,1,1);
cdfplot(temp);
% plot(DE,y)
ax1.XDir = ‘reverse’;
set(gca, ‘YScale’, ‘log’)
figure();
pd_HOLT = fitdist(total_HOLT,’Normal’);
DE_HOLT = bingroups_HOLT;
y_HOLT = pdf(pd_HOLT,DE_HOLT);
ax1 = subplot(1,1,1);
plot(DE_HOLT,y_HOLT)
ax1.XDir = ‘reverse’;
set(gca, ‘YScale’, ‘log’)
The x-axis is the same. How can I multiply these plots to convey a (qualitative) idea? Thanks. probability, distribution, multiply MATLAB Answers — New Questions
How do I solve “pyrunfile is not suppoted” error in MATLAB Function ?
I got these errors in MATLAB Function. I tried everything but I couldn’t figure out how to solve. I’m not sure.
Could you give me any advice? I’d be happy if you could tell me why this happens and where I’m missing.
Also, I’m now executing this model on MATLAB Online.
Error1
The function ‘pyrunfile’ is not supported in code generation.
Function ‘MATLAB Function’ (#24.95.220), line 2, column 13:.
“pyrunfile(“scikit_learn_model.py”, “output_vars”,in1=input1,in2=input2,in3=input3")
Error2
Terminal width or dimension error.
‘Output terminal 1’ in ‘MATLAB Function/input7’ is a 1-dimensional vector with 1 element
Here is my .slx model.
Also, Here is my MATLAB Function code.
function [trq,brake] = RunPython(input1,input2,input3,input4,input5,input6,input7)
outputs=pyrunfile("scikit_learn_model.py","output_vars",in1=input1,in2=input2,in3=input3,in4=input4,in5=input5,in6=input6,in7=input7);
trq=outputs(1);
brake=outputs(2);
end
scikit_learn_model.py
import pickle
with open(‘surrogate_model.pkl’, ‘rb’) as f:
model = pickle.load(f)
inputs = [in1,in2,in3,in4,in5,in6,in7]
output1, output2 = model.predict(inputs)
output_vars=[output1,output2]I got these errors in MATLAB Function. I tried everything but I couldn’t figure out how to solve. I’m not sure.
Could you give me any advice? I’d be happy if you could tell me why this happens and where I’m missing.
Also, I’m now executing this model on MATLAB Online.
Error1
The function ‘pyrunfile’ is not supported in code generation.
Function ‘MATLAB Function’ (#24.95.220), line 2, column 13:.
“pyrunfile(“scikit_learn_model.py”, “output_vars”,in1=input1,in2=input2,in3=input3")
Error2
Terminal width or dimension error.
‘Output terminal 1’ in ‘MATLAB Function/input7’ is a 1-dimensional vector with 1 element
Here is my .slx model.
Also, Here is my MATLAB Function code.
function [trq,brake] = RunPython(input1,input2,input3,input4,input5,input6,input7)
outputs=pyrunfile("scikit_learn_model.py","output_vars",in1=input1,in2=input2,in3=input3,in4=input4,in5=input5,in6=input6,in7=input7);
trq=outputs(1);
brake=outputs(2);
end
scikit_learn_model.py
import pickle
with open(‘surrogate_model.pkl’, ‘rb’) as f:
model = pickle.load(f)
inputs = [in1,in2,in3,in4,in5,in6,in7]
output1, output2 = model.predict(inputs)
output_vars=[output1,output2] I got these errors in MATLAB Function. I tried everything but I couldn’t figure out how to solve. I’m not sure.
Could you give me any advice? I’d be happy if you could tell me why this happens and where I’m missing.
Also, I’m now executing this model on MATLAB Online.
Error1
The function ‘pyrunfile’ is not supported in code generation.
Function ‘MATLAB Function’ (#24.95.220), line 2, column 13:.
“pyrunfile(“scikit_learn_model.py”, “output_vars”,in1=input1,in2=input2,in3=input3")
Error2
Terminal width or dimension error.
‘Output terminal 1’ in ‘MATLAB Function/input7’ is a 1-dimensional vector with 1 element
Here is my .slx model.
Also, Here is my MATLAB Function code.
function [trq,brake] = RunPython(input1,input2,input3,input4,input5,input6,input7)
outputs=pyrunfile("scikit_learn_model.py","output_vars",in1=input1,in2=input2,in3=input3,in4=input4,in5=input5,in6=input6,in7=input7);
trq=outputs(1);
brake=outputs(2);
end
scikit_learn_model.py
import pickle
with open(‘surrogate_model.pkl’, ‘rb’) as f:
model = pickle.load(f)
inputs = [in1,in2,in3,in4,in5,in6,in7]
output1, output2 = model.predict(inputs)
output_vars=[output1,output2] python, matlab function MATLAB Answers — New Questions
Is it possible to make Machine Learning model to predict multiple outputs with Statistics and Machine Learning Toolbox?
I’d like to create a model to predict two output signals based on the following seven input signals, by using Statistics and Machine Learning Toolbox.
This csv is a the data (about 4,200 rows) used as training data.
This data is a time series every 0.025 seconds.
I think the model type is Regressin model if you create a model from this data.
(Data type of each Signal is double type.)
Input Signals:
V_TGT_Vehicle
P_DCDC_PNT_W
P_HVAC_PNT_W
SOC_BT_Hi_PNT_per
open_accel_Driver_per
open_break_Driver_per
w_MG_PNT_radps
Output Signals:
trq_MG2_tgtCalc1
trq_MG2_tgtCalc2
I’ve been going through Statistics and Machine Learning Toolbox documentation, I’m not sure if it’s possible to create a machine learning model like above.
I’d like to export the model as Simulink block.
Do you have any ideas?
How do I make this with Statistics and Machine Learning Toolbox?I’d like to create a model to predict two output signals based on the following seven input signals, by using Statistics and Machine Learning Toolbox.
This csv is a the data (about 4,200 rows) used as training data.
This data is a time series every 0.025 seconds.
I think the model type is Regressin model if you create a model from this data.
(Data type of each Signal is double type.)
Input Signals:
V_TGT_Vehicle
P_DCDC_PNT_W
P_HVAC_PNT_W
SOC_BT_Hi_PNT_per
open_accel_Driver_per
open_break_Driver_per
w_MG_PNT_radps
Output Signals:
trq_MG2_tgtCalc1
trq_MG2_tgtCalc2
I’ve been going through Statistics and Machine Learning Toolbox documentation, I’m not sure if it’s possible to create a machine learning model like above.
I’d like to export the model as Simulink block.
Do you have any ideas?
How do I make this with Statistics and Machine Learning Toolbox? I’d like to create a model to predict two output signals based on the following seven input signals, by using Statistics and Machine Learning Toolbox.
This csv is a the data (about 4,200 rows) used as training data.
This data is a time series every 0.025 seconds.
I think the model type is Regressin model if you create a model from this data.
(Data type of each Signal is double type.)
Input Signals:
V_TGT_Vehicle
P_DCDC_PNT_W
P_HVAC_PNT_W
SOC_BT_Hi_PNT_per
open_accel_Driver_per
open_break_Driver_per
w_MG_PNT_radps
Output Signals:
trq_MG2_tgtCalc1
trq_MG2_tgtCalc2
I’ve been going through Statistics and Machine Learning Toolbox documentation, I’m not sure if it’s possible to create a machine learning model like above.
I’d like to export the model as Simulink block.
Do you have any ideas?
How do I make this with Statistics and Machine Learning Toolbox? machine learning MATLAB Answers — New Questions
Colormap generated using the information of different arrays
Hello everyone
I am trying to plot the data in five different matrices in the same graphic. Interestingly, the elements of these matrices are not equal to NaN just in the spatial domain where, each of them, should exists. In principle, if the matrix element (i,j) of one of these matrices is different from NaN, it would not be again non-NaN in the other data arrays at (i,j). The five different matrices can be found here.
I would like to make the NaN elements to be completely transparent. As you can see, I am attaching a colormap, "Colors.txt", which is not white at the middle. I do not know if that makes any difference.
I am plotting the system as follows:
p1=uimagesc(Space_a,Space_b,mz_Tetra_1_Data);
set(p1,’alphadata’,~isnan(mz_Tetra_1_Data));
hold on
p2=uimagesc(Space_a,Space_b,mz_Tetra_2_Data);
set(p2,’alphadata’,~isnan(mz_Tetra_2_Data));
p3=uimagesc(Space_a,Space_b,mz_Penta_1_Data);
set(p3,’alphadata’,~isnan(mz_Penta_1_Data));
p4=uimagesc(Space_a,Space_b,mz_Penta_2_Data);
set(p4,’alphadata’,~isnan(mz_Penta_2_Data));
p5=uimagesc(Space_a,Space_b,mz_Hexa_Data);
set(p5,’alphadata’,~isnan(mz_Hexa_Data));
colormap(Colors);
clim([-1 1]);
Is the code above correct for my purpose?Hello everyone
I am trying to plot the data in five different matrices in the same graphic. Interestingly, the elements of these matrices are not equal to NaN just in the spatial domain where, each of them, should exists. In principle, if the matrix element (i,j) of one of these matrices is different from NaN, it would not be again non-NaN in the other data arrays at (i,j). The five different matrices can be found here.
I would like to make the NaN elements to be completely transparent. As you can see, I am attaching a colormap, "Colors.txt", which is not white at the middle. I do not know if that makes any difference.
I am plotting the system as follows:
p1=uimagesc(Space_a,Space_b,mz_Tetra_1_Data);
set(p1,’alphadata’,~isnan(mz_Tetra_1_Data));
hold on
p2=uimagesc(Space_a,Space_b,mz_Tetra_2_Data);
set(p2,’alphadata’,~isnan(mz_Tetra_2_Data));
p3=uimagesc(Space_a,Space_b,mz_Penta_1_Data);
set(p3,’alphadata’,~isnan(mz_Penta_1_Data));
p4=uimagesc(Space_a,Space_b,mz_Penta_2_Data);
set(p4,’alphadata’,~isnan(mz_Penta_2_Data));
p5=uimagesc(Space_a,Space_b,mz_Hexa_Data);
set(p5,’alphadata’,~isnan(mz_Hexa_Data));
colormap(Colors);
clim([-1 1]);
Is the code above correct for my purpose? Hello everyone
I am trying to plot the data in five different matrices in the same graphic. Interestingly, the elements of these matrices are not equal to NaN just in the spatial domain where, each of them, should exists. In principle, if the matrix element (i,j) of one of these matrices is different from NaN, it would not be again non-NaN in the other data arrays at (i,j). The five different matrices can be found here.
I would like to make the NaN elements to be completely transparent. As you can see, I am attaching a colormap, "Colors.txt", which is not white at the middle. I do not know if that makes any difference.
I am plotting the system as follows:
p1=uimagesc(Space_a,Space_b,mz_Tetra_1_Data);
set(p1,’alphadata’,~isnan(mz_Tetra_1_Data));
hold on
p2=uimagesc(Space_a,Space_b,mz_Tetra_2_Data);
set(p2,’alphadata’,~isnan(mz_Tetra_2_Data));
p3=uimagesc(Space_a,Space_b,mz_Penta_1_Data);
set(p3,’alphadata’,~isnan(mz_Penta_1_Data));
p4=uimagesc(Space_a,Space_b,mz_Penta_2_Data);
set(p4,’alphadata’,~isnan(mz_Penta_2_Data));
p5=uimagesc(Space_a,Space_b,mz_Hexa_Data);
set(p5,’alphadata’,~isnan(mz_Hexa_Data));
colormap(Colors);
clim([-1 1]);
Is the code above correct for my purpose? imagesc with nan elements being transparent MATLAB Answers — New Questions
Graphical User Interface problem with Simulink Design Optimization Toolbox
I am having problems with several windows in SDO GUI in MATLAB versions 2024a and 2024b (not before): I can see some buttons. Is there any solution?I am having problems with several windows in SDO GUI in MATLAB versions 2024a and 2024b (not before): I can see some buttons. Is there any solution? I am having problems with several windows in SDO GUI in MATLAB versions 2024a and 2024b (not before): I can see some buttons. Is there any solution? gui, graphical user interface MATLAB Answers — New Questions
print() and saveas() produce svg files where text is stored as paths and not text – how to overcome?
I am trying to export an .svg image of a matlab figure (see attachement) to convert it afterwards in Inkscape to a .pdf_tex file to include it in a nice way into my latex document. However when trying to export it with eiter print() or saveas() it always saves the labels as vector graphics paths and not as text. This makes it afterwards unfeasible to save the text of the image (labels, etc) as propper text for the latex file.
I have so far tried multiple things:
% Open the figure
openfig("25m_baseline_smoothing.fig");
h = gcf();
h.Renderer = "painters"; % To make sure I have a vector image
% Trial 1
print("25m_baseline_smoothing","-dsvg"); % Produces paths
% Trial 2
saveas(h, "25m_baseline_smoothing","svg"); % Produces paths, not text
Futher I also tried to save the figure with the menu in the figure dropdown menu (File > Save as…). I also tried to directly export the figure with matlab2tikz. This is not a solution either as matlab2tikz can’t handle a tiled layout yet.
Is there a way to overcome this problem and export the labes directly as text to the .svg image?
Kind regards,I am trying to export an .svg image of a matlab figure (see attachement) to convert it afterwards in Inkscape to a .pdf_tex file to include it in a nice way into my latex document. However when trying to export it with eiter print() or saveas() it always saves the labels as vector graphics paths and not as text. This makes it afterwards unfeasible to save the text of the image (labels, etc) as propper text for the latex file.
I have so far tried multiple things:
% Open the figure
openfig("25m_baseline_smoothing.fig");
h = gcf();
h.Renderer = "painters"; % To make sure I have a vector image
% Trial 1
print("25m_baseline_smoothing","-dsvg"); % Produces paths
% Trial 2
saveas(h, "25m_baseline_smoothing","svg"); % Produces paths, not text
Futher I also tried to save the figure with the menu in the figure dropdown menu (File > Save as…). I also tried to directly export the figure with matlab2tikz. This is not a solution either as matlab2tikz can’t handle a tiled layout yet.
Is there a way to overcome this problem and export the labes directly as text to the .svg image?
Kind regards, I am trying to export an .svg image of a matlab figure (see attachement) to convert it afterwards in Inkscape to a .pdf_tex file to include it in a nice way into my latex document. However when trying to export it with eiter print() or saveas() it always saves the labels as vector graphics paths and not as text. This makes it afterwards unfeasible to save the text of the image (labels, etc) as propper text for the latex file.
I have so far tried multiple things:
% Open the figure
openfig("25m_baseline_smoothing.fig");
h = gcf();
h.Renderer = "painters"; % To make sure I have a vector image
% Trial 1
print("25m_baseline_smoothing","-dsvg"); % Produces paths
% Trial 2
saveas(h, "25m_baseline_smoothing","svg"); % Produces paths, not text
Futher I also tried to save the figure with the menu in the figure dropdown menu (File > Save as…). I also tried to directly export the figure with matlab2tikz. This is not a solution either as matlab2tikz can’t handle a tiled layout yet.
Is there a way to overcome this problem and export the labes directly as text to the .svg image?
Kind regards, svg, figure MATLAB Answers — New Questions
too many input arguments
trying to install 3rd party software. matlab syas "error too many input arguments". i am using c2000 blockset.trying to install 3rd party software. matlab syas "error too many input arguments". i am using c2000 blockset. trying to install 3rd party software. matlab syas "error too many input arguments". i am using c2000 blockset. c2000, error MATLAB Answers — New Questions
How do I skip items in a legend?
How do I skip items in legend? Say I have 6 plots with 3 actual values and 3 interpolated curves. I only want to label the actual value curves so
legend(‘first’,”,’second’,”,’third’)
doesn’t really work because the interpolated curve still shows.How do I skip items in legend? Say I have 6 plots with 3 actual values and 3 interpolated curves. I only want to label the actual value curves so
legend(‘first’,”,’second’,”,’third’)
doesn’t really work because the interpolated curve still shows. How do I skip items in legend? Say I have 6 plots with 3 actual values and 3 interpolated curves. I only want to label the actual value curves so
legend(‘first’,”,’second’,”,’third’)
doesn’t really work because the interpolated curve still shows. MATLAB Answers — New Questions
How to optimize IF statement with Multiple Conditions.
Hello,
I have five Tables (T1 to T5) and Conditons CR ranging from ( 0-4) . When I process a files each file may have one condition in it or multiple conditons. For example ( it could have Condition 3 or in the next file it could be 0,2 & 4). Which ever condtiion is satisfied that particular table (if one condition) and (Multiple table Verticat into one final table).
I tried using multiple methods like
1) If any or all statments didn’t work.
2) if I have to use ismember then I could have make multiple array of condition hard coded into the script. Example: Condition:if ismember([1 2], CR]’
Final_Table = verticat(T2;T3).
Could someone suggest a robust and quicker way.
If possible provide with a Script sketon or example so It could be understood better and also your time and effort is well respected.
Thank youHello,
I have five Tables (T1 to T5) and Conditons CR ranging from ( 0-4) . When I process a files each file may have one condition in it or multiple conditons. For example ( it could have Condition 3 or in the next file it could be 0,2 & 4). Which ever condtiion is satisfied that particular table (if one condition) and (Multiple table Verticat into one final table).
I tried using multiple methods like
1) If any or all statments didn’t work.
2) if I have to use ismember then I could have make multiple array of condition hard coded into the script. Example: Condition:if ismember([1 2], CR]’
Final_Table = verticat(T2;T3).
Could someone suggest a robust and quicker way.
If possible provide with a Script sketon or example so It could be understood better and also your time and effort is well respected.
Thank you Hello,
I have five Tables (T1 to T5) and Conditons CR ranging from ( 0-4) . When I process a files each file may have one condition in it or multiple conditons. For example ( it could have Condition 3 or in the next file it could be 0,2 & 4). Which ever condtiion is satisfied that particular table (if one condition) and (Multiple table Verticat into one final table).
I tried using multiple methods like
1) If any or all statments didn’t work.
2) if I have to use ismember then I could have make multiple array of condition hard coded into the script. Example: Condition:if ismember([1 2], CR]’
Final_Table = verticat(T2;T3).
Could someone suggest a robust and quicker way.
If possible provide with a Script sketon or example so It could be understood better and also your time and effort is well respected.
Thank you if statement, multiple conditions MATLAB Answers — New Questions
Smooth noisy data whilst keep absolute minimum and maximum values
I have a reasonably noisy signal (almost sinusoidal) that I am smoothing using sgolayfilt.
I am using a polynomial of 2 with a frame length of 901.
I am happy with the smoothing using this frame length.
However, there are several parts of the signal that need to have (correctly) a minimum value of zero.
When I smooth the signal the value of the minima are no longer zero. The lowest value of the smoothed curve at the minima takes a non-zero value, that might be positive or negative.
If I "shift" the curve then only one of the minima is zero.
Is there a method to smooth curves whilst keeping absolute minimum (and maximum if required) values? Or is it always a trade-off (I could trace the signal by eye very well, using a drawing package, keeping the minima, but I want to automate the process with matlab)
regardsI have a reasonably noisy signal (almost sinusoidal) that I am smoothing using sgolayfilt.
I am using a polynomial of 2 with a frame length of 901.
I am happy with the smoothing using this frame length.
However, there are several parts of the signal that need to have (correctly) a minimum value of zero.
When I smooth the signal the value of the minima are no longer zero. The lowest value of the smoothed curve at the minima takes a non-zero value, that might be positive or negative.
If I "shift" the curve then only one of the minima is zero.
Is there a method to smooth curves whilst keeping absolute minimum (and maximum if required) values? Or is it always a trade-off (I could trace the signal by eye very well, using a drawing package, keeping the minima, but I want to automate the process with matlab)
regards I have a reasonably noisy signal (almost sinusoidal) that I am smoothing using sgolayfilt.
I am using a polynomial of 2 with a frame length of 901.
I am happy with the smoothing using this frame length.
However, there are several parts of the signal that need to have (correctly) a minimum value of zero.
When I smooth the signal the value of the minima are no longer zero. The lowest value of the smoothed curve at the minima takes a non-zero value, that might be positive or negative.
If I "shift" the curve then only one of the minima is zero.
Is there a method to smooth curves whilst keeping absolute minimum (and maximum if required) values? Or is it always a trade-off (I could trace the signal by eye very well, using a drawing package, keeping the minima, but I want to automate the process with matlab)
regards smoothing, signal, sgolay, baseline correction MATLAB Answers — New Questions
Want to remove white patches of a image
Guys,
I have a problem this is a jewelry photo that i have uploaded what i need to do is remove the white bright spot that is often appearing on the gold surfaces as well as the gemstones, these are the reflection of the lighting setup. What i am planning to do is find out the region of high white intensity that is with RGB values over 220 and then replace them by the average shade of the pixels around them, thus removing those white patches. Is this possible?
Thanks a lot guys.
<</matlabcentral/answers/uploaded_files/15159/SAM_0304.JPG>>Guys,
I have a problem this is a jewelry photo that i have uploaded what i need to do is remove the white bright spot that is often appearing on the gold surfaces as well as the gemstones, these are the reflection of the lighting setup. What i am planning to do is find out the region of high white intensity that is with RGB values over 220 and then replace them by the average shade of the pixels around them, thus removing those white patches. Is this possible?
Thanks a lot guys.
<</matlabcentral/answers/uploaded_files/15159/SAM_0304.JPG>> Guys,
I have a problem this is a jewelry photo that i have uploaded what i need to do is remove the white bright spot that is often appearing on the gold surfaces as well as the gemstones, these are the reflection of the lighting setup. What i am planning to do is find out the region of high white intensity that is with RGB values over 220 and then replace them by the average shade of the pixels around them, thus removing those white patches. Is this possible?
Thanks a lot guys.
<</matlabcentral/answers/uploaded_files/15159/SAM_0304.JPG>> image processing, image analysis MATLAB Answers — New Questions
model reduction from a database created with xfoil
Hello community,
i have created a database with xfoil (2d airfoil panel code with an boundary solver).
The database is saved in this format:
% L lift
% D drag
% al angle of attack
% thick thickness of the airfoil
% camber camber of the airfoil
% Ma Mach number
% Re Reynolds number
L = db_L(al, thick, camber, Ma, Re);
D = db_D(al, thick, camber, Ma, Re);
The easiest way is a lookup-table, but i am looking for a more sophisticated approach like a POD (proper orthogonal decompositon) to identify e.g. how sensitive the thickness affect the lift.
if every input variable consist of 16 values, the database has 16^5 entries, and i could create Matrix of 1024 x1024 for the POD analysis.
but how could i compare the results of the modes with the data base? e.g. the deviation of the lift for a specific case.
PS: is there an application or something in Matlab which could help me?
best regards
emjayHello community,
i have created a database with xfoil (2d airfoil panel code with an boundary solver).
The database is saved in this format:
% L lift
% D drag
% al angle of attack
% thick thickness of the airfoil
% camber camber of the airfoil
% Ma Mach number
% Re Reynolds number
L = db_L(al, thick, camber, Ma, Re);
D = db_D(al, thick, camber, Ma, Re);
The easiest way is a lookup-table, but i am looking for a more sophisticated approach like a POD (proper orthogonal decompositon) to identify e.g. how sensitive the thickness affect the lift.
if every input variable consist of 16 values, the database has 16^5 entries, and i could create Matrix of 1024 x1024 for the POD analysis.
but how could i compare the results of the modes with the data base? e.g. the deviation of the lift for a specific case.
PS: is there an application or something in Matlab which could help me?
best regards
emjay Hello community,
i have created a database with xfoil (2d airfoil panel code with an boundary solver).
The database is saved in this format:
% L lift
% D drag
% al angle of attack
% thick thickness of the airfoil
% camber camber of the airfoil
% Ma Mach number
% Re Reynolds number
L = db_L(al, thick, camber, Ma, Re);
D = db_D(al, thick, camber, Ma, Re);
The easiest way is a lookup-table, but i am looking for a more sophisticated approach like a POD (proper orthogonal decompositon) to identify e.g. how sensitive the thickness affect the lift.
if every input variable consist of 16 values, the database has 16^5 entries, and i could create Matrix of 1024 x1024 for the POD analysis.
but how could i compare the results of the modes with the data base? e.g. the deviation of the lift for a specific case.
PS: is there an application or something in Matlab which could help me?
best regards
emjay pod MATLAB Answers — New Questions
I want to connect 30MW PV power plant to pre-built IEEE 9 bus system what is the easier way to do that in other words is there a block in the library?
in MAATLAB Simulink i want to add PV power plant to the power systemin MAATLAB Simulink i want to add PV power plant to the power system in MAATLAB Simulink i want to add PV power plant to the power system urgent MATLAB Answers — New Questions
Can I include only specific MATLAB DLL files, like “MathWorks.MATLAB.Types.dll”, in an external .NET application?
I am using MATLAB R2023b on Windows. I am creating a separate application in .NET, where I would like to only use specific MATLAB .NET datatypes, like "MathWorks.MATLAB.Types.MATLABStruct".
These data types are located in the "MathWorks.MATLAB.Types.dll" file in
C:Program FilesMATLABR2023bexterndotnetnetstandard2.0
.
I am not passing any data into MATLAB, as this is a testing application that is just testing type conversion.
Is there any way to only include specific MATLAB DLL files in a .NET application, or would I need to have either MATLAB or MATLAB Runtime installed on a machine that is running this application?I am using MATLAB R2023b on Windows. I am creating a separate application in .NET, where I would like to only use specific MATLAB .NET datatypes, like "MathWorks.MATLAB.Types.MATLABStruct".
These data types are located in the "MathWorks.MATLAB.Types.dll" file in
C:Program FilesMATLABR2023bexterndotnetnetstandard2.0
.
I am not passing any data into MATLAB, as this is a testing application that is just testing type conversion.
Is there any way to only include specific MATLAB DLL files in a .NET application, or would I need to have either MATLAB or MATLAB Runtime installed on a machine that is running this application? I am using MATLAB R2023b on Windows. I am creating a separate application in .NET, where I would like to only use specific MATLAB .NET datatypes, like "MathWorks.MATLAB.Types.MATLABStruct".
These data types are located in the "MathWorks.MATLAB.Types.dll" file in
C:Program FilesMATLABR2023bexterndotnetnetstandard2.0
.
I am not passing any data into MATLAB, as this is a testing application that is just testing type conversion.
Is there any way to only include specific MATLAB DLL files in a .NET application, or would I need to have either MATLAB or MATLAB Runtime installed on a machine that is running this application? dotnet, matlabruntime, matlabstruct, dll MATLAB Answers — New Questions
Using tabular data for Curve fitting of function z = f (x, y) with incomplete values of z. These blank z (i, j) automatically takes zero values and this is a problem
Dear Community Members,
I have tabular data for data selection in the Curve fitter in the form of:.
I have to use curve fitter for z = f (x, y), but I don’t have values for z(2, 4), z(3,3) and z(3,4) (red one).
In the workspase variable (matrix Z) these blank places automatically take values, which is zeros. Is there any instrument to ignore these zeros and the regression analyses to be made only with the available z values. In other words to ignore the three zero values in the down right corner? May be something with the weights instrument? If I simply use the matrix with zero values, without any additional actions, of course the regression method uses these z(2, 4) = 0, z(3,3) = 0 and z(3,4) = 0 and the results are unacceptable.Dear Community Members,
I have tabular data for data selection in the Curve fitter in the form of:.
I have to use curve fitter for z = f (x, y), but I don’t have values for z(2, 4), z(3,3) and z(3,4) (red one).
In the workspase variable (matrix Z) these blank places automatically take values, which is zeros. Is there any instrument to ignore these zeros and the regression analyses to be made only with the available z values. In other words to ignore the three zero values in the down right corner? May be something with the weights instrument? If I simply use the matrix with zero values, without any additional actions, of course the regression method uses these z(2, 4) = 0, z(3,3) = 0 and z(3,4) = 0 and the results are unacceptable. Dear Community Members,
I have tabular data for data selection in the Curve fitter in the form of:.
I have to use curve fitter for z = f (x, y), but I don’t have values for z(2, 4), z(3,3) and z(3,4) (red one).
In the workspase variable (matrix Z) these blank places automatically take values, which is zeros. Is there any instrument to ignore these zeros and the regression analyses to be made only with the available z values. In other words to ignore the three zero values in the down right corner? May be something with the weights instrument? If I simply use the matrix with zero values, without any additional actions, of course the regression method uses these z(2, 4) = 0, z(3,3) = 0 and z(3,4) = 0 and the results are unacceptable. ignore zeros in input data for curve fitter MATLAB Answers — New Questions