Category: Matlab
Category Archives: Matlab
What part of this training and testing steps need(s) to be modified to get the correct missing rate?
I got missing rate = 1 with this attached code, but my class’s auto grading system says it’s incorrect.
What part of this training and testing steps need(s) to be modified to get the correct missing rate?
[Current Code]
load("C:UsersxxooxOneDriveデスクトップMATLAB worksComputer Vision for Engineering and ScienceC2-MachineLearningForComputerVisionModule 4WoodKnotsGroundTruth.mat");
testPath = overwriteGTruthLocations(gTruthTrain);
imageLabeler(gTruthTrain)
imageLabeler(testPath)
load("C:UsersxxooxOneDriveデスクトップMATLAB worksComputer Vision for Engineering and ScienceC2-MachineLearningForComputerVisionModule 4WoodKnotsGroundTruthTest2.mat");
imdsTest = imageDatastore(testPath);
gTruth.LabelDefinitions
gTruth.DataSource
gTruth.LabelData
objectTrainingData = objectDetectorTrainingData(gTruthTrain)
acfDetector = trainACFObjectDetector(objectTrainingData)
imdsTest = imageDatastore(testPath)
bboxes = detect(acfDetector,imdsTest)
evaluateDetectionMissRate(bboxes,gTruthTest.LabelData)I got missing rate = 1 with this attached code, but my class’s auto grading system says it’s incorrect.
What part of this training and testing steps need(s) to be modified to get the correct missing rate?
[Current Code]
load("C:UsersxxooxOneDriveデスクトップMATLAB worksComputer Vision for Engineering and ScienceC2-MachineLearningForComputerVisionModule 4WoodKnotsGroundTruth.mat");
testPath = overwriteGTruthLocations(gTruthTrain);
imageLabeler(gTruthTrain)
imageLabeler(testPath)
load("C:UsersxxooxOneDriveデスクトップMATLAB worksComputer Vision for Engineering and ScienceC2-MachineLearningForComputerVisionModule 4WoodKnotsGroundTruthTest2.mat");
imdsTest = imageDatastore(testPath);
gTruth.LabelDefinitions
gTruth.DataSource
gTruth.LabelData
objectTrainingData = objectDetectorTrainingData(gTruthTrain)
acfDetector = trainACFObjectDetector(objectTrainingData)
imdsTest = imageDatastore(testPath)
bboxes = detect(acfDetector,imdsTest)
evaluateDetectionMissRate(bboxes,gTruthTest.LabelData) I got missing rate = 1 with this attached code, but my class’s auto grading system says it’s incorrect.
What part of this training and testing steps need(s) to be modified to get the correct missing rate?
[Current Code]
load("C:UsersxxooxOneDriveデスクトップMATLAB worksComputer Vision for Engineering and ScienceC2-MachineLearningForComputerVisionModule 4WoodKnotsGroundTruth.mat");
testPath = overwriteGTruthLocations(gTruthTrain);
imageLabeler(gTruthTrain)
imageLabeler(testPath)
load("C:UsersxxooxOneDriveデスクトップMATLAB worksComputer Vision for Engineering and ScienceC2-MachineLearningForComputerVisionModule 4WoodKnotsGroundTruthTest2.mat");
imdsTest = imageDatastore(testPath);
gTruth.LabelDefinitions
gTruth.DataSource
gTruth.LabelData
objectTrainingData = objectDetectorTrainingData(gTruthTrain)
acfDetector = trainACFObjectDetector(objectTrainingData)
imdsTest = imageDatastore(testPath)
bboxes = detect(acfDetector,imdsTest)
evaluateDetectionMissRate(bboxes,gTruthTest.LabelData) matlab, machine learning, testing, training, image labeling MATLAB Answers — New Questions
How can i link between ansys workbench and matlab to make optimization ?
How can i link between ansys workbench and matlab to make optimization ?
Note : the geomtry is imported from solidworksHow can i link between ansys workbench and matlab to make optimization ?
Note : the geomtry is imported from solidworks How can i link between ansys workbench and matlab to make optimization ?
Note : the geomtry is imported from solidworks ansys, optimization MATLAB Answers — New Questions
Compile-time size assumption error in Simulink function script
I’m encountering a compile-time size assumption violation error when attempting to run my MATLAB code with code generation.
I am working with a column vector ffeout_lp which has the dimensions 63680×1, and an integer oversample which is set to 40. I am quite new to scripting in simulink, so what I have tried so far may not have been optimal. The ‘coder.varsize’ statements above are to initialize space for arrays, as to my knowledge dynamic initializing is not permitted for code generation. How do I go about this compile time error?
Thanks!I’m encountering a compile-time size assumption violation error when attempting to run my MATLAB code with code generation.
I am working with a column vector ffeout_lp which has the dimensions 63680×1, and an integer oversample which is set to 40. I am quite new to scripting in simulink, so what I have tried so far may not have been optimal. The ‘coder.varsize’ statements above are to initialize space for arrays, as to my knowledge dynamic initializing is not permitted for code generation. How do I go about this compile time error?
Thanks! I’m encountering a compile-time size assumption violation error when attempting to run my MATLAB code with code generation.
I am working with a column vector ffeout_lp which has the dimensions 63680×1, and an integer oversample which is set to 40. I am quite new to scripting in simulink, so what I have tried so far may not have been optimal. The ‘coder.varsize’ statements above are to initialize space for arrays, as to my knowledge dynamic initializing is not permitted for code generation. How do I go about this compile time error?
Thanks! simulink, compile time size assumption, matlab function, signal processing, code generation MATLAB Answers — New Questions
Is there a way to increase the default ping timeout time for MATLAB Ethernet AXI manager for Xilinx FPGA?
Is there a way to increase the default ping timeout time for MATLAB Ethernet axi manager? Ethernet is so delicate that sometimes it can fail to ping quickly. But unfortunately MATLAB throws a timeout error quickly. Now if you are running a long experiment, and suddenly it gets timed out, it is very bad and sad. Rather we could wait longer for that Ethernet to ping.
So, my question is: is there a way to increase the default ping timeout time for MATLAB Ethernet AXI manager for Xilinx FPGA? If not, can we come up with a workaround?Is there a way to increase the default ping timeout time for MATLAB Ethernet axi manager? Ethernet is so delicate that sometimes it can fail to ping quickly. But unfortunately MATLAB throws a timeout error quickly. Now if you are running a long experiment, and suddenly it gets timed out, it is very bad and sad. Rather we could wait longer for that Ethernet to ping.
So, my question is: is there a way to increase the default ping timeout time for MATLAB Ethernet AXI manager for Xilinx FPGA? If not, can we come up with a workaround? Is there a way to increase the default ping timeout time for MATLAB Ethernet axi manager? Ethernet is so delicate that sometimes it can fail to ping quickly. But unfortunately MATLAB throws a timeout error quickly. Now if you are running a long experiment, and suddenly it gets timed out, it is very bad and sad. Rather we could wait longer for that Ethernet to ping.
So, my question is: is there a way to increase the default ping timeout time for MATLAB Ethernet AXI manager for Xilinx FPGA? If not, can we come up with a workaround? ethernet MATLAB Answers — New Questions
Disable logging to disk from Simulink, during Reinforcement Learning training
I’m using the train function to run a Reinforcement Learning training using a PPO agent, with a rlSimulinkEnv object defining the environment.
Regarding the rlTrainingOptions, I’m using the default option for "SimulationStorageType", which is "memory". So I expect (if I understand correctly) that all the simulation data should be saved to RAM, not to disk, whenever possible. However I noticed that Simulink is actually saving the simulation data into .dmr files stored in my TEMPDIR.
I also tried to disable the Simulink logging to TEMPDIR directly from the Simulink Data Inspector, setting the Record Mode to "View during simulation only". However, as soon as I start the Reinforcement Learning Training, the simulation data are still saved as .dmr files in my TEMPDIR.
Is there a way to actually avoid saving .dmr files to TEMPDIR when training in a Simulink environment, and instead using only RAM to store the simulation data as long as the Matlab session is active?
I’m using version R2024aI’m using the train function to run a Reinforcement Learning training using a PPO agent, with a rlSimulinkEnv object defining the environment.
Regarding the rlTrainingOptions, I’m using the default option for "SimulationStorageType", which is "memory". So I expect (if I understand correctly) that all the simulation data should be saved to RAM, not to disk, whenever possible. However I noticed that Simulink is actually saving the simulation data into .dmr files stored in my TEMPDIR.
I also tried to disable the Simulink logging to TEMPDIR directly from the Simulink Data Inspector, setting the Record Mode to "View during simulation only". However, as soon as I start the Reinforcement Learning Training, the simulation data are still saved as .dmr files in my TEMPDIR.
Is there a way to actually avoid saving .dmr files to TEMPDIR when training in a Simulink environment, and instead using only RAM to store the simulation data as long as the Matlab session is active?
I’m using version R2024a I’m using the train function to run a Reinforcement Learning training using a PPO agent, with a rlSimulinkEnv object defining the environment.
Regarding the rlTrainingOptions, I’m using the default option for "SimulationStorageType", which is "memory". So I expect (if I understand correctly) that all the simulation data should be saved to RAM, not to disk, whenever possible. However I noticed that Simulink is actually saving the simulation data into .dmr files stored in my TEMPDIR.
I also tried to disable the Simulink logging to TEMPDIR directly from the Simulink Data Inspector, setting the Record Mode to "View during simulation only". However, as soon as I start the Reinforcement Learning Training, the simulation data are still saved as .dmr files in my TEMPDIR.
Is there a way to actually avoid saving .dmr files to TEMPDIR when training in a Simulink environment, and instead using only RAM to store the simulation data as long as the Matlab session is active?
I’m using version R2024a simulink, data MATLAB Answers — New Questions
Save/Load Simulink Code-Generated State
Is it possible to save/serialize the internal state structs of a Simulink code-generated model, and re-load those on a later initialization?
To prevent X/Y problem, I am using a GRT code-generated Simulink model to simulate a specific plant. My controls are neccessarily but unfortunately outside of Matlab/Simulink. I would like to modify parameters in a control scheme and assess their performance over a specific region of the simulation. Essentially like in a video game, you may fail some challenge and you are restarted at some checkpoint.
I have tried using a reusable function, and then use the tool ‘cser’ to serialize the main model struct, however it quickly gets confused with the vast number of types pointing to other types. Additionally, some of the structs contain pointers, so I can’t simply write the memory of the struct to a file.Is it possible to save/serialize the internal state structs of a Simulink code-generated model, and re-load those on a later initialization?
To prevent X/Y problem, I am using a GRT code-generated Simulink model to simulate a specific plant. My controls are neccessarily but unfortunately outside of Matlab/Simulink. I would like to modify parameters in a control scheme and assess their performance over a specific region of the simulation. Essentially like in a video game, you may fail some challenge and you are restarted at some checkpoint.
I have tried using a reusable function, and then use the tool ‘cser’ to serialize the main model struct, however it quickly gets confused with the vast number of types pointing to other types. Additionally, some of the structs contain pointers, so I can’t simply write the memory of the struct to a file. Is it possible to save/serialize the internal state structs of a Simulink code-generated model, and re-load those on a later initialization?
To prevent X/Y problem, I am using a GRT code-generated Simulink model to simulate a specific plant. My controls are neccessarily but unfortunately outside of Matlab/Simulink. I would like to modify parameters in a control scheme and assess their performance over a specific region of the simulation. Essentially like in a video game, you may fail some challenge and you are restarted at some checkpoint.
I have tried using a reusable function, and then use the tool ‘cser’ to serialize the main model struct, however it quickly gets confused with the vast number of types pointing to other types. Additionally, some of the structs contain pointers, so I can’t simply write the memory of the struct to a file. code generation, simulink, simulation, serialization MATLAB Answers — New Questions
How to create Simulink model with multiple versions?
I have Simulink models that are different versions of a controller. The versions change static data, used throughout the model, and some blocks in the model. I am wondering if there is a way to create one Simulink model that can be changed between all these versions. A similar functionality exists in standard Simulink functions, such as with the PID Controller when you switch the form between Parallel and Ideal or the Logical Operator switching between AND and OR. Has anyone created or found similar functionality for making Simulink models with different versions?I have Simulink models that are different versions of a controller. The versions change static data, used throughout the model, and some blocks in the model. I am wondering if there is a way to create one Simulink model that can be changed between all these versions. A similar functionality exists in standard Simulink functions, such as with the PID Controller when you switch the form between Parallel and Ideal or the Logical Operator switching between AND and OR. Has anyone created or found similar functionality for making Simulink models with different versions? I have Simulink models that are different versions of a controller. The versions change static data, used throughout the model, and some blocks in the model. I am wondering if there is a way to create one Simulink model that can be changed between all these versions. A similar functionality exists in standard Simulink functions, such as with the PID Controller when you switch the form between Parallel and Ideal or the Logical Operator switching between AND and OR. Has anyone created or found similar functionality for making Simulink models with different versions? simulink, version, static data MATLAB Answers — New Questions
Is Oracle Java JRE license included with Matlab license?
Hi!
Our IT department found that an Oracle JRE is installed as part of Matlab (R2020a on Windows). Since Oracle changed its licensing policy a while ago, such that in many cases now JRE installations have to be paid for, we are concerned about what to do here, eg whether we need to pay Oracle for this JRE embedded into Matlab.
Does our Matlab license also cover the right to use the embedded JRE? Under what conditions?
Maybe there is even an according Matlab license statement somewhere?
Thanks!Hi!
Our IT department found that an Oracle JRE is installed as part of Matlab (R2020a on Windows). Since Oracle changed its licensing policy a while ago, such that in many cases now JRE installations have to be paid for, we are concerned about what to do here, eg whether we need to pay Oracle for this JRE embedded into Matlab.
Does our Matlab license also cover the right to use the embedded JRE? Under what conditions?
Maybe there is even an according Matlab license statement somewhere?
Thanks! Hi!
Our IT department found that an Oracle JRE is installed as part of Matlab (R2020a on Windows). Since Oracle changed its licensing policy a while ago, such that in many cases now JRE installations have to be paid for, we are concerned about what to do here, eg whether we need to pay Oracle for this JRE embedded into Matlab.
Does our Matlab license also cover the right to use the embedded JRE? Under what conditions?
Maybe there is even an according Matlab license statement somewhere?
Thanks! java, jre, license, oracle MATLAB Answers — New Questions
custom library HX711 Index exceeds the number of array elements. Index must not exceed 2.
% Copyright 2018, Nicholas Giacoboni
%
% Redistribution and use in source and binary forms, with or without
% modification, are permitted provided that the following conditions are met:
%
% 1. Redistributions of source code must retain the above copyright
% notice, this list of conditions and the following disclaimer.
%
% 2. Redistributions in binary form must reproduce the above copyright
% notice, this list of conditions and the following disclaimer in the
% documentation and/or other materials provided with the distribution.
%
% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
% WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
% IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
% INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
% NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
% PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
% WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
% OF SUCH DAMAGE.
%**************************************************************************
classdef basic_HX711 < matlabshared.addon.LibraryBase
properties(Access = protected)
Pins %Data and Clock pin
end
properties (Access = private, Constant = true)
READ_HX711 = hex2dec(’01’)
end
properties(Access = protected, Constant = true)
LibraryName = ‘basicHX711/basic_HX711’
DependentLibraries = {}
LibraryHeaderFiles = {}
CppHeaderFile = fullfile(arduinoio.FilePath(mfilename(‘fullpath’)), ‘src’, ‘basic_HX711.h’)
CppClassName = ‘basic_HX711’
end
methods(Hidden, Access = public)
function obj = basic_HX711(parentObj,inputPins)
obj.Parent = parentObj;
obj.Pins = getTerminalsFromPins(obj.Parent,inputPins);
configurePin(parentObj,inputPins{2},’DigitalInput’); % Data Pin
configurePin(parentObj,inputPins{3},’DigitalOutput’); % Clock Pin
end
end
methods(Access = public)
function force = read_HX711(obj)
cmdID = obj.READ_HX711;
inputs = obj.Pins;
value = sendCommand(obj, obj.LibraryName, cmdID, inputs);
value(3)=bitshift(value(3),16);
value(2)=bitshift(value(2),8);
force = bitor(value(3),bitor(value(2),value(1)));
end
end
end
%**************************************************************************
listArduinoLibraries
ans =
12×1 cell array
{‘APDS9960’ }
{‘Adafruit/MotorShieldV2’}
{‘CAN’ }
{‘I2C’ }
{‘MotorCarrier’ }
{‘RotaryEncoder’ }
{‘SPI’ }
{‘Serial’ }
{‘Servo’ }
{‘ShiftRegister’ }
{‘Ultrasonic’ }
{‘basicHX711/basic_HX711’}
a = arduino(‘COM6’, ‘Uno’, ‘Libraries’,’basicHX711/basic_HX711′,’ForceBuildOn’,’True’);
>> Loadcell = addon(a,’basicHX711/basic_HX711′,{‘D2′,’D3’})
Index exceeds the number of array elements. Index must not exceed 2.
%**************************************************************************
I’m currently working on creating a custom library for the HX711 sensor, but I’m encountering an issue with the ‘Index exceeds the number of array elements. Index must not exceed 2.’ I hope someone can help me troubleshoot.% Copyright 2018, Nicholas Giacoboni
%
% Redistribution and use in source and binary forms, with or without
% modification, are permitted provided that the following conditions are met:
%
% 1. Redistributions of source code must retain the above copyright
% notice, this list of conditions and the following disclaimer.
%
% 2. Redistributions in binary form must reproduce the above copyright
% notice, this list of conditions and the following disclaimer in the
% documentation and/or other materials provided with the distribution.
%
% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
% WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
% IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
% INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
% NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
% PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
% WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
% OF SUCH DAMAGE.
%**************************************************************************
classdef basic_HX711 < matlabshared.addon.LibraryBase
properties(Access = protected)
Pins %Data and Clock pin
end
properties (Access = private, Constant = true)
READ_HX711 = hex2dec(’01’)
end
properties(Access = protected, Constant = true)
LibraryName = ‘basicHX711/basic_HX711’
DependentLibraries = {}
LibraryHeaderFiles = {}
CppHeaderFile = fullfile(arduinoio.FilePath(mfilename(‘fullpath’)), ‘src’, ‘basic_HX711.h’)
CppClassName = ‘basic_HX711’
end
methods(Hidden, Access = public)
function obj = basic_HX711(parentObj,inputPins)
obj.Parent = parentObj;
obj.Pins = getTerminalsFromPins(obj.Parent,inputPins);
configurePin(parentObj,inputPins{2},’DigitalInput’); % Data Pin
configurePin(parentObj,inputPins{3},’DigitalOutput’); % Clock Pin
end
end
methods(Access = public)
function force = read_HX711(obj)
cmdID = obj.READ_HX711;
inputs = obj.Pins;
value = sendCommand(obj, obj.LibraryName, cmdID, inputs);
value(3)=bitshift(value(3),16);
value(2)=bitshift(value(2),8);
force = bitor(value(3),bitor(value(2),value(1)));
end
end
end
%**************************************************************************
listArduinoLibraries
ans =
12×1 cell array
{‘APDS9960’ }
{‘Adafruit/MotorShieldV2’}
{‘CAN’ }
{‘I2C’ }
{‘MotorCarrier’ }
{‘RotaryEncoder’ }
{‘SPI’ }
{‘Serial’ }
{‘Servo’ }
{‘ShiftRegister’ }
{‘Ultrasonic’ }
{‘basicHX711/basic_HX711’}
a = arduino(‘COM6’, ‘Uno’, ‘Libraries’,’basicHX711/basic_HX711′,’ForceBuildOn’,’True’);
>> Loadcell = addon(a,’basicHX711/basic_HX711′,{‘D2′,’D3’})
Index exceeds the number of array elements. Index must not exceed 2.
%**************************************************************************
I’m currently working on creating a custom library for the HX711 sensor, but I’m encountering an issue with the ‘Index exceeds the number of array elements. Index must not exceed 2.’ I hope someone can help me troubleshoot. % Copyright 2018, Nicholas Giacoboni
%
% Redistribution and use in source and binary forms, with or without
% modification, are permitted provided that the following conditions are met:
%
% 1. Redistributions of source code must retain the above copyright
% notice, this list of conditions and the following disclaimer.
%
% 2. Redistributions in binary form must reproduce the above copyright
% notice, this list of conditions and the following disclaimer in the
% documentation and/or other materials provided with the distribution.
%
% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
% WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
% IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
% INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
% NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
% PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
% WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
% OF SUCH DAMAGE.
%**************************************************************************
classdef basic_HX711 < matlabshared.addon.LibraryBase
properties(Access = protected)
Pins %Data and Clock pin
end
properties (Access = private, Constant = true)
READ_HX711 = hex2dec(’01’)
end
properties(Access = protected, Constant = true)
LibraryName = ‘basicHX711/basic_HX711’
DependentLibraries = {}
LibraryHeaderFiles = {}
CppHeaderFile = fullfile(arduinoio.FilePath(mfilename(‘fullpath’)), ‘src’, ‘basic_HX711.h’)
CppClassName = ‘basic_HX711’
end
methods(Hidden, Access = public)
function obj = basic_HX711(parentObj,inputPins)
obj.Parent = parentObj;
obj.Pins = getTerminalsFromPins(obj.Parent,inputPins);
configurePin(parentObj,inputPins{2},’DigitalInput’); % Data Pin
configurePin(parentObj,inputPins{3},’DigitalOutput’); % Clock Pin
end
end
methods(Access = public)
function force = read_HX711(obj)
cmdID = obj.READ_HX711;
inputs = obj.Pins;
value = sendCommand(obj, obj.LibraryName, cmdID, inputs);
value(3)=bitshift(value(3),16);
value(2)=bitshift(value(2),8);
force = bitor(value(3),bitor(value(2),value(1)));
end
end
end
%**************************************************************************
listArduinoLibraries
ans =
12×1 cell array
{‘APDS9960’ }
{‘Adafruit/MotorShieldV2’}
{‘CAN’ }
{‘I2C’ }
{‘MotorCarrier’ }
{‘RotaryEncoder’ }
{‘SPI’ }
{‘Serial’ }
{‘Servo’ }
{‘ShiftRegister’ }
{‘Ultrasonic’ }
{‘basicHX711/basic_HX711’}
a = arduino(‘COM6’, ‘Uno’, ‘Libraries’,’basicHX711/basic_HX711′,’ForceBuildOn’,’True’);
>> Loadcell = addon(a,’basicHX711/basic_HX711′,{‘D2′,’D3’})
Index exceeds the number of array elements. Index must not exceed 2.
%**************************************************************************
I’m currently working on creating a custom library for the HX711 sensor, but I’m encountering an issue with the ‘Index exceeds the number of array elements. Index must not exceed 2.’ I hope someone can help me troubleshoot. matlab addon, hx711 MATLAB Answers — New Questions
Regarding the GUI update to change the slider values.
Dear Friends Hello,
I have a querry I request to please help.
I have created a GUI where the values is gratting is selected from the ‘select_gratting’ as shownin attached figure. I want to change the slider limits based on gratting selected. For example currently it shows – 30 to 550 for 1200 gratting values, but when 2400 gratting selected I want slider limit to change and show 30 to 250 without closing the GUI.
I request to please help, how can I do this.
Thanking you,
Kind regardsDear Friends Hello,
I have a querry I request to please help.
I have created a GUI where the values is gratting is selected from the ‘select_gratting’ as shownin attached figure. I want to change the slider limits based on gratting selected. For example currently it shows – 30 to 550 for 1200 gratting values, but when 2400 gratting selected I want slider limit to change and show 30 to 250 without closing the GUI.
I request to please help, how can I do this.
Thanking you,
Kind regards Dear Friends Hello,
I have a querry I request to please help.
I have created a GUI where the values is gratting is selected from the ‘select_gratting’ as shownin attached figure. I want to change the slider limits based on gratting selected. For example currently it shows – 30 to 550 for 1200 gratting values, but when 2400 gratting selected I want slider limit to change and show 30 to 250 without closing the GUI.
I request to please help, how can I do this.
Thanking you,
Kind regards gui, matlab, slider MATLAB Answers — New Questions
Shapefile not overlapping perfectly over pcolor plot
I am trying to plot a pcolor plot for Sea surface temperature data set and to represent the coastaline in the plot i have downloadwed global coastline shapefile and when i am using geoshow to read and overlay on the pcolor plot it is not matching perfectlyI am trying to plot a pcolor plot for Sea surface temperature data set and to represent the coastaline in the plot i have downloadwed global coastline shapefile and when i am using geoshow to read and overlay on the pcolor plot it is not matching perfectly I am trying to plot a pcolor plot for Sea surface temperature data set and to represent the coastaline in the plot i have downloadwed global coastline shapefile and when i am using geoshow to read and overlay on the pcolor plot it is not matching perfectly geoshow, shapefile, pcolor plot MATLAB Answers — New Questions
Plotting a 3d hydrogen atomic orbital plot from a data file
I have a data file of two colums, column1 has data of radial coordinate ‘r’ and column2 has data of ‘wavefunction’ of 3d orbital both are 1D arrays of each 45 entries. I need to obtain a 3D plot in cartesian coordinates ‘wavefunction(x,y,z)’ after multiplying the corresponding spherical harmonic functions of 3dz^2. How to get one. I am very new to MATLAB any help would be appreciated.
The data is as follows:
0.00 0.000000
0.45 0.000627
0.90 0.002467
1.35 0.005404
1.80 0.009263
2.25 0.013828
2.70 0.018859
3.15 0.024107
3.60 0.029329
4.05 0.034296
4.50 0.038798
4.95 0.042653
5.40 0.045707
5.85 0.047850
6.30 0.049018
6.75 0.049205
7.20 0.048467
7.65 0.046926
8.10 0.044759
8.55 0.042183
9.00 0.039422
9.45 0.036660
9.90 0.033972
10.35 0.031248
10.80 0.028078
11.25 0.023511
11.70 0.016026
12.15 0.005061
12.60 -.006867
13.05 -.014665
13.50 -.014647
13.95 -.007211
14.40 0.003441
14.85 0.011842
15.30 0.015687
15.75 0.016839
16.20 0.016349
16.65 0.014982
17.10 0.013238
17.55 0.011416
18.00 0.009680
18.45 0.008110
18.90 0.006736
19.35 0.005560
19.80 0.004567I have a data file of two colums, column1 has data of radial coordinate ‘r’ and column2 has data of ‘wavefunction’ of 3d orbital both are 1D arrays of each 45 entries. I need to obtain a 3D plot in cartesian coordinates ‘wavefunction(x,y,z)’ after multiplying the corresponding spherical harmonic functions of 3dz^2. How to get one. I am very new to MATLAB any help would be appreciated.
The data is as follows:
0.00 0.000000
0.45 0.000627
0.90 0.002467
1.35 0.005404
1.80 0.009263
2.25 0.013828
2.70 0.018859
3.15 0.024107
3.60 0.029329
4.05 0.034296
4.50 0.038798
4.95 0.042653
5.40 0.045707
5.85 0.047850
6.30 0.049018
6.75 0.049205
7.20 0.048467
7.65 0.046926
8.10 0.044759
8.55 0.042183
9.00 0.039422
9.45 0.036660
9.90 0.033972
10.35 0.031248
10.80 0.028078
11.25 0.023511
11.70 0.016026
12.15 0.005061
12.60 -.006867
13.05 -.014665
13.50 -.014647
13.95 -.007211
14.40 0.003441
14.85 0.011842
15.30 0.015687
15.75 0.016839
16.20 0.016349
16.65 0.014982
17.10 0.013238
17.55 0.011416
18.00 0.009680
18.45 0.008110
18.90 0.006736
19.35 0.005560
19.80 0.004567 I have a data file of two colums, column1 has data of radial coordinate ‘r’ and column2 has data of ‘wavefunction’ of 3d orbital both are 1D arrays of each 45 entries. I need to obtain a 3D plot in cartesian coordinates ‘wavefunction(x,y,z)’ after multiplying the corresponding spherical harmonic functions of 3dz^2. How to get one. I am very new to MATLAB any help would be appreciated.
The data is as follows:
0.00 0.000000
0.45 0.000627
0.90 0.002467
1.35 0.005404
1.80 0.009263
2.25 0.013828
2.70 0.018859
3.15 0.024107
3.60 0.029329
4.05 0.034296
4.50 0.038798
4.95 0.042653
5.40 0.045707
5.85 0.047850
6.30 0.049018
6.75 0.049205
7.20 0.048467
7.65 0.046926
8.10 0.044759
8.55 0.042183
9.00 0.039422
9.45 0.036660
9.90 0.033972
10.35 0.031248
10.80 0.028078
11.25 0.023511
11.70 0.016026
12.15 0.005061
12.60 -.006867
13.05 -.014665
13.50 -.014647
13.95 -.007211
14.40 0.003441
14.85 0.011842
15.30 0.015687
15.75 0.016839
16.20 0.016349
16.65 0.014982
17.10 0.013238
17.55 0.011416
18.00 0.009680
18.45 0.008110
18.90 0.006736
19.35 0.005560
19.80 0.004567 3dz^2 orbital plot MATLAB Answers — New Questions
sltest.harness.create function input ‘source’ can’t be set ‘Signal Builder’ in parameter pairs in matlab 2022b
sltest.harness.create(‘Harness_Test’,’Source’,’Signal editor’,’Sink’,’Outport’);
error:
Expected input to match one of these values:
‘Inport’, ‘Signal Editor’, ‘From Workspace’, ‘From File’, ‘Test Sequence’, ‘Chart’, ‘Constant’, ‘Ground’, ‘None’, ‘Custom’
The input, ‘Signal Builder’, did not match any of the valid values.
This means I can’t assign ‘Signal Builder’ to ‘Source’, matlab version is 2022b, but there is no error in 2022a(Tested many times).
Is this issue related to matlab version and how to solve it? Still need to use ‘Signal Builder’.sltest.harness.create(‘Harness_Test’,’Source’,’Signal editor’,’Sink’,’Outport’);
error:
Expected input to match one of these values:
‘Inport’, ‘Signal Editor’, ‘From Workspace’, ‘From File’, ‘Test Sequence’, ‘Chart’, ‘Constant’, ‘Ground’, ‘None’, ‘Custom’
The input, ‘Signal Builder’, did not match any of the valid values.
This means I can’t assign ‘Signal Builder’ to ‘Source’, matlab version is 2022b, but there is no error in 2022a(Tested many times).
Is this issue related to matlab version and how to solve it? Still need to use ‘Signal Builder’. sltest.harness.create(‘Harness_Test’,’Source’,’Signal editor’,’Sink’,’Outport’);
error:
Expected input to match one of these values:
‘Inport’, ‘Signal Editor’, ‘From Workspace’, ‘From File’, ‘Test Sequence’, ‘Chart’, ‘Constant’, ‘Ground’, ‘None’, ‘Custom’
The input, ‘Signal Builder’, did not match any of the valid values.
This means I can’t assign ‘Signal Builder’ to ‘Source’, matlab version is 2022b, but there is no error in 2022a(Tested many times).
Is this issue related to matlab version and how to solve it? Still need to use ‘Signal Builder’. sltest.harness.create MATLAB Answers — New Questions
How do I solve this error in Parameter Setting for 2-D Lookup Table Block in Simulink?
I’m trying to create a surrogate model for vehicle dynamics in Simulink, but I’m encountering an error when setting parameters for the 2-D Lookup Table block. I would greatly appreciate any advice.
When executing the following code, this error occurs.
set_param([modelName ‘/SurrogateModel’], …
‘RowIndex’, mat2str(throttleBreakpoints), …
‘ColumnIndex’, mat2str(brakeBreakpoints), …
‘Table’, mat2str(speedData));
Error message:
There is no parameter named ‘RowIndex’ in the Lookup_n-D block
I can’t figure out how I can solve this kind of error.
I was wondering if you could give me a solution.
How should I modify the code?
Here is my matlab script to create the surrogate model.
Full Script
% Create a surrogate model for vehicle longitudinal dynamics
% Set model name
modelName = ‘VehicleLongitudinalSurrogate’;
% Create new Simulink model
new_system(modelName);
open_system(modelName);
% Input: Throttle position (0-100%)
add_block(‘simulink/Sources/In1’, [modelName ‘/Throttle’]);
set_param([modelName ‘/Throttle’], ‘Position’, [100, 100, 130, 130]);
% Input: Brake pressure (0-100%)
add_block(‘simulink/Sources/In1’, [modelName ‘/Brake’]);
set_param([modelName ‘/Brake’], ‘Position’, [100, 200, 130, 230]);
% Surrogate model (Lookup table)
add_block(‘simulink/Lookup Tables/2-D Lookup Table’, [modelName ‘/SurrogateModel’]);
set_param([modelName ‘/SurrogateModel’], ‘Position’, [250, 140, 350, 190]);
% Output: Vehicle speed (km/h)
add_block(‘simulink/Sinks/Out1’, [modelName ‘/Speed’]);
set_param([modelName ‘/Speed’], ‘Position’, [450, 160, 480, 190]);
% Connect blocks
add_line(modelName, ‘Throttle/1’, ‘SurrogateModel/1’, ‘autorouting’, ‘on’);
add_line(modelName, ‘Brake/1’, ‘SurrogateModel/2’, ‘autorouting’, ‘on’);
add_line(modelName, ‘SurrogateModel/1’, ‘Speed/1’, ‘autorouting’, ‘on’);
% Set lookup table parameters (simplified data)
throttleBreakpoints = 0:20:100;
brakeBreakpoints = 0:20:100;
speedData = [
120, 100, 80, 60, 40, 20;
100, 80, 60, 40, 20, 0;
80, 60, 40, 20, 0, 0;
60, 40, 20, 0, 0, 0;
40, 20, 0, 0, 0, 0;
20, 0, 0, 0, 0, 0
];
% Set parameters (this is where the error occurs)
set_param([modelName ‘/SurrogateModel’], …
‘RowIndex’, mat2str(throttleBreakpoints), …
‘ColumnIndex’, mat2str(brakeBreakpoints), …
‘Table’, mat2str(speedData));
% Save and close the model
save_system(modelName, [modelName ‘.slx’]);
close_system(modelName);
disp(‘Vehicle longitudinal dynamics surrogate model has been created and saved.’);
Best,I’m trying to create a surrogate model for vehicle dynamics in Simulink, but I’m encountering an error when setting parameters for the 2-D Lookup Table block. I would greatly appreciate any advice.
When executing the following code, this error occurs.
set_param([modelName ‘/SurrogateModel’], …
‘RowIndex’, mat2str(throttleBreakpoints), …
‘ColumnIndex’, mat2str(brakeBreakpoints), …
‘Table’, mat2str(speedData));
Error message:
There is no parameter named ‘RowIndex’ in the Lookup_n-D block
I can’t figure out how I can solve this kind of error.
I was wondering if you could give me a solution.
How should I modify the code?
Here is my matlab script to create the surrogate model.
Full Script
% Create a surrogate model for vehicle longitudinal dynamics
% Set model name
modelName = ‘VehicleLongitudinalSurrogate’;
% Create new Simulink model
new_system(modelName);
open_system(modelName);
% Input: Throttle position (0-100%)
add_block(‘simulink/Sources/In1’, [modelName ‘/Throttle’]);
set_param([modelName ‘/Throttle’], ‘Position’, [100, 100, 130, 130]);
% Input: Brake pressure (0-100%)
add_block(‘simulink/Sources/In1’, [modelName ‘/Brake’]);
set_param([modelName ‘/Brake’], ‘Position’, [100, 200, 130, 230]);
% Surrogate model (Lookup table)
add_block(‘simulink/Lookup Tables/2-D Lookup Table’, [modelName ‘/SurrogateModel’]);
set_param([modelName ‘/SurrogateModel’], ‘Position’, [250, 140, 350, 190]);
% Output: Vehicle speed (km/h)
add_block(‘simulink/Sinks/Out1’, [modelName ‘/Speed’]);
set_param([modelName ‘/Speed’], ‘Position’, [450, 160, 480, 190]);
% Connect blocks
add_line(modelName, ‘Throttle/1’, ‘SurrogateModel/1’, ‘autorouting’, ‘on’);
add_line(modelName, ‘Brake/1’, ‘SurrogateModel/2’, ‘autorouting’, ‘on’);
add_line(modelName, ‘SurrogateModel/1’, ‘Speed/1’, ‘autorouting’, ‘on’);
% Set lookup table parameters (simplified data)
throttleBreakpoints = 0:20:100;
brakeBreakpoints = 0:20:100;
speedData = [
120, 100, 80, 60, 40, 20;
100, 80, 60, 40, 20, 0;
80, 60, 40, 20, 0, 0;
60, 40, 20, 0, 0, 0;
40, 20, 0, 0, 0, 0;
20, 0, 0, 0, 0, 0
];
% Set parameters (this is where the error occurs)
set_param([modelName ‘/SurrogateModel’], …
‘RowIndex’, mat2str(throttleBreakpoints), …
‘ColumnIndex’, mat2str(brakeBreakpoints), …
‘Table’, mat2str(speedData));
% Save and close the model
save_system(modelName, [modelName ‘.slx’]);
close_system(modelName);
disp(‘Vehicle longitudinal dynamics surrogate model has been created and saved.’);
Best, I’m trying to create a surrogate model for vehicle dynamics in Simulink, but I’m encountering an error when setting parameters for the 2-D Lookup Table block. I would greatly appreciate any advice.
When executing the following code, this error occurs.
set_param([modelName ‘/SurrogateModel’], …
‘RowIndex’, mat2str(throttleBreakpoints), …
‘ColumnIndex’, mat2str(brakeBreakpoints), …
‘Table’, mat2str(speedData));
Error message:
There is no parameter named ‘RowIndex’ in the Lookup_n-D block
I can’t figure out how I can solve this kind of error.
I was wondering if you could give me a solution.
How should I modify the code?
Here is my matlab script to create the surrogate model.
Full Script
% Create a surrogate model for vehicle longitudinal dynamics
% Set model name
modelName = ‘VehicleLongitudinalSurrogate’;
% Create new Simulink model
new_system(modelName);
open_system(modelName);
% Input: Throttle position (0-100%)
add_block(‘simulink/Sources/In1’, [modelName ‘/Throttle’]);
set_param([modelName ‘/Throttle’], ‘Position’, [100, 100, 130, 130]);
% Input: Brake pressure (0-100%)
add_block(‘simulink/Sources/In1’, [modelName ‘/Brake’]);
set_param([modelName ‘/Brake’], ‘Position’, [100, 200, 130, 230]);
% Surrogate model (Lookup table)
add_block(‘simulink/Lookup Tables/2-D Lookup Table’, [modelName ‘/SurrogateModel’]);
set_param([modelName ‘/SurrogateModel’], ‘Position’, [250, 140, 350, 190]);
% Output: Vehicle speed (km/h)
add_block(‘simulink/Sinks/Out1’, [modelName ‘/Speed’]);
set_param([modelName ‘/Speed’], ‘Position’, [450, 160, 480, 190]);
% Connect blocks
add_line(modelName, ‘Throttle/1’, ‘SurrogateModel/1’, ‘autorouting’, ‘on’);
add_line(modelName, ‘Brake/1’, ‘SurrogateModel/2’, ‘autorouting’, ‘on’);
add_line(modelName, ‘SurrogateModel/1’, ‘Speed/1’, ‘autorouting’, ‘on’);
% Set lookup table parameters (simplified data)
throttleBreakpoints = 0:20:100;
brakeBreakpoints = 0:20:100;
speedData = [
120, 100, 80, 60, 40, 20;
100, 80, 60, 40, 20, 0;
80, 60, 40, 20, 0, 0;
60, 40, 20, 0, 0, 0;
40, 20, 0, 0, 0, 0;
20, 0, 0, 0, 0, 0
];
% Set parameters (this is where the error occurs)
set_param([modelName ‘/SurrogateModel’], …
‘RowIndex’, mat2str(throttleBreakpoints), …
‘ColumnIndex’, mat2str(brakeBreakpoints), …
‘Table’, mat2str(speedData));
% Save and close the model
save_system(modelName, [modelName ‘.slx’]);
close_system(modelName);
disp(‘Vehicle longitudinal dynamics surrogate model has been created and saved.’);
Best, simulink, matlab code MATLAB Answers — New Questions
Speed up numeric integral
Hi,everyone.I got a problem of doing numeric integral on the matrix H (which is at the bottom part of my code).
The code works fine but I would like to speed it up? Am I doing something stupid to make it slow?Thanks for your help.
clear
L=0.1;
section=50;
a=L./2;
b=L./section;
v=3e8;
f1=1.2e9;
f2=4.8e9;
f3=7.5e9;
f4=10e9;
w1=(2.*pi.*f1);
w2=(2.*pi.*f2);
w3=(2.*pi.*f3);
w4=(2.*pi.*f4);
Z01=50;
Z02=75;
a0=(log(Z02./Z01))./(2..*L);
T=a;
Ub=a;
Lb=-a;
ub=a;
lb=-a;
k=5;
syms x y w m
%%% Revised Algorithm
l=0:(2.*L)./(2.*k):L % Approximate sections dvided
% Approximate terms
sec=numel(l)-1;
Z1=[50 55 60 65 70 80 75]; % Set the impedance of the end of each sections
ac=10; % Choose the accuracy of dividing a section
for s=1:1:sec
c=(l(s+1)-l(s))./ac;
app_cos=0.5./ac.*log(Z1(s+1)./Z1(s)).*sin(ac./2.*(w./v).*c).*cos(((ac+1)./2).*(w./v).*c)./sin(((c.*w)./(2.*v)));
app_sin=0.5./ac.*log(Z1(s+1)./Z1(s)).*sin(ac./2.*(w./v).*c).*sin(((ac+1)./2).*(w./v).*c)./sin(((c.*w)./(2.*v)));
amp=0.75;
Ga(s)=(app_cos-(1i.*amp.*app_sin));
end
Ta=(1-(abs(Ga(1:1:end)).^2));
%%% Turn closed loop terms into matrix presentation
for t=1:1:sec
for r=1:1:sec
E(t,r)=Ga(t).*Ga(r);
end
end
E=triu(E,1);
for t=1:1:sec
for r=1:1:sec
D(t,r)=abs(E(r,t));
end
end
C1=sum(D);
% Construct approximate loop terms
for t=1:1:sec
D1(t)=prod(Ta(1:t))./(1+(sum(C1(1:t))));
end
D=[1 D1(2:end)];
Dm=transpose(D).*D;
% Cmn
m=transpose(1:5);
n=1:5;
g=(v.^2.*w.^2.*cos((2.*w.*(- y + x))./v).*cos(20.*sym(pi).*m.*x).*cos(20.*sym(pi).*n.*y) + 10.*sym(pi).*m.*v.^3.*w.*sin(20.*sym(pi).*m.*x).*sin((2.*w.*(- y + x))./v).*cos(20.*sym(pi).*n.*y) – 10.*sym(pi).*n.*v.^3.*w.*sin(20.*sym(pi).*n.*y).*sin((2.*w.*(- y + x))./v).*cos(20.*sym(pi).*m.*x) + 100.*m.*n.*v.^4.*sym(pi).^2.*sin(20.*sym(pi).*m.*x).*sin(20.*sym(pi).*n.*y).*cos((2.*w.*(- y + x))./v))./(4.*(w.^2 – 100.*sym(pi).^2.*m.^2.*v.^2).*(w.^2 – 100.*sym(pi).^2.*n.^2.*v.^2));
for p=1:numel(l)-1
x1=l(p);
x2=l(p+1);
for q=1:numel(l)-1
y1=l(q);
y2=l(p+1);
Ht{p,q}=matlabFunction(((subs(g,[x y],[x2 y2])-subs(g,[x y],[x1 y1]))*Dm(p,q)));
end
end
Hi=Ht{1};
for m=2:1:numel(Ht)
Hi=Hi+vpa(Ht{m},3);
end
H=integral(Hi,w1,w2,"ArrayValued",true)Hi,everyone.I got a problem of doing numeric integral on the matrix H (which is at the bottom part of my code).
The code works fine but I would like to speed it up? Am I doing something stupid to make it slow?Thanks for your help.
clear
L=0.1;
section=50;
a=L./2;
b=L./section;
v=3e8;
f1=1.2e9;
f2=4.8e9;
f3=7.5e9;
f4=10e9;
w1=(2.*pi.*f1);
w2=(2.*pi.*f2);
w3=(2.*pi.*f3);
w4=(2.*pi.*f4);
Z01=50;
Z02=75;
a0=(log(Z02./Z01))./(2..*L);
T=a;
Ub=a;
Lb=-a;
ub=a;
lb=-a;
k=5;
syms x y w m
%%% Revised Algorithm
l=0:(2.*L)./(2.*k):L % Approximate sections dvided
% Approximate terms
sec=numel(l)-1;
Z1=[50 55 60 65 70 80 75]; % Set the impedance of the end of each sections
ac=10; % Choose the accuracy of dividing a section
for s=1:1:sec
c=(l(s+1)-l(s))./ac;
app_cos=0.5./ac.*log(Z1(s+1)./Z1(s)).*sin(ac./2.*(w./v).*c).*cos(((ac+1)./2).*(w./v).*c)./sin(((c.*w)./(2.*v)));
app_sin=0.5./ac.*log(Z1(s+1)./Z1(s)).*sin(ac./2.*(w./v).*c).*sin(((ac+1)./2).*(w./v).*c)./sin(((c.*w)./(2.*v)));
amp=0.75;
Ga(s)=(app_cos-(1i.*amp.*app_sin));
end
Ta=(1-(abs(Ga(1:1:end)).^2));
%%% Turn closed loop terms into matrix presentation
for t=1:1:sec
for r=1:1:sec
E(t,r)=Ga(t).*Ga(r);
end
end
E=triu(E,1);
for t=1:1:sec
for r=1:1:sec
D(t,r)=abs(E(r,t));
end
end
C1=sum(D);
% Construct approximate loop terms
for t=1:1:sec
D1(t)=prod(Ta(1:t))./(1+(sum(C1(1:t))));
end
D=[1 D1(2:end)];
Dm=transpose(D).*D;
% Cmn
m=transpose(1:5);
n=1:5;
g=(v.^2.*w.^2.*cos((2.*w.*(- y + x))./v).*cos(20.*sym(pi).*m.*x).*cos(20.*sym(pi).*n.*y) + 10.*sym(pi).*m.*v.^3.*w.*sin(20.*sym(pi).*m.*x).*sin((2.*w.*(- y + x))./v).*cos(20.*sym(pi).*n.*y) – 10.*sym(pi).*n.*v.^3.*w.*sin(20.*sym(pi).*n.*y).*sin((2.*w.*(- y + x))./v).*cos(20.*sym(pi).*m.*x) + 100.*m.*n.*v.^4.*sym(pi).^2.*sin(20.*sym(pi).*m.*x).*sin(20.*sym(pi).*n.*y).*cos((2.*w.*(- y + x))./v))./(4.*(w.^2 – 100.*sym(pi).^2.*m.^2.*v.^2).*(w.^2 – 100.*sym(pi).^2.*n.^2.*v.^2));
for p=1:numel(l)-1
x1=l(p);
x2=l(p+1);
for q=1:numel(l)-1
y1=l(q);
y2=l(p+1);
Ht{p,q}=matlabFunction(((subs(g,[x y],[x2 y2])-subs(g,[x y],[x1 y1]))*Dm(p,q)));
end
end
Hi=Ht{1};
for m=2:1:numel(Ht)
Hi=Hi+vpa(Ht{m},3);
end
H=integral(Hi,w1,w2,"ArrayValued",true) Hi,everyone.I got a problem of doing numeric integral on the matrix H (which is at the bottom part of my code).
The code works fine but I would like to speed it up? Am I doing something stupid to make it slow?Thanks for your help.
clear
L=0.1;
section=50;
a=L./2;
b=L./section;
v=3e8;
f1=1.2e9;
f2=4.8e9;
f3=7.5e9;
f4=10e9;
w1=(2.*pi.*f1);
w2=(2.*pi.*f2);
w3=(2.*pi.*f3);
w4=(2.*pi.*f4);
Z01=50;
Z02=75;
a0=(log(Z02./Z01))./(2..*L);
T=a;
Ub=a;
Lb=-a;
ub=a;
lb=-a;
k=5;
syms x y w m
%%% Revised Algorithm
l=0:(2.*L)./(2.*k):L % Approximate sections dvided
% Approximate terms
sec=numel(l)-1;
Z1=[50 55 60 65 70 80 75]; % Set the impedance of the end of each sections
ac=10; % Choose the accuracy of dividing a section
for s=1:1:sec
c=(l(s+1)-l(s))./ac;
app_cos=0.5./ac.*log(Z1(s+1)./Z1(s)).*sin(ac./2.*(w./v).*c).*cos(((ac+1)./2).*(w./v).*c)./sin(((c.*w)./(2.*v)));
app_sin=0.5./ac.*log(Z1(s+1)./Z1(s)).*sin(ac./2.*(w./v).*c).*sin(((ac+1)./2).*(w./v).*c)./sin(((c.*w)./(2.*v)));
amp=0.75;
Ga(s)=(app_cos-(1i.*amp.*app_sin));
end
Ta=(1-(abs(Ga(1:1:end)).^2));
%%% Turn closed loop terms into matrix presentation
for t=1:1:sec
for r=1:1:sec
E(t,r)=Ga(t).*Ga(r);
end
end
E=triu(E,1);
for t=1:1:sec
for r=1:1:sec
D(t,r)=abs(E(r,t));
end
end
C1=sum(D);
% Construct approximate loop terms
for t=1:1:sec
D1(t)=prod(Ta(1:t))./(1+(sum(C1(1:t))));
end
D=[1 D1(2:end)];
Dm=transpose(D).*D;
% Cmn
m=transpose(1:5);
n=1:5;
g=(v.^2.*w.^2.*cos((2.*w.*(- y + x))./v).*cos(20.*sym(pi).*m.*x).*cos(20.*sym(pi).*n.*y) + 10.*sym(pi).*m.*v.^3.*w.*sin(20.*sym(pi).*m.*x).*sin((2.*w.*(- y + x))./v).*cos(20.*sym(pi).*n.*y) – 10.*sym(pi).*n.*v.^3.*w.*sin(20.*sym(pi).*n.*y).*sin((2.*w.*(- y + x))./v).*cos(20.*sym(pi).*m.*x) + 100.*m.*n.*v.^4.*sym(pi).^2.*sin(20.*sym(pi).*m.*x).*sin(20.*sym(pi).*n.*y).*cos((2.*w.*(- y + x))./v))./(4.*(w.^2 – 100.*sym(pi).^2.*m.^2.*v.^2).*(w.^2 – 100.*sym(pi).^2.*n.^2.*v.^2));
for p=1:numel(l)-1
x1=l(p);
x2=l(p+1);
for q=1:numel(l)-1
y1=l(q);
y2=l(p+1);
Ht{p,q}=matlabFunction(((subs(g,[x y],[x2 y2])-subs(g,[x y],[x1 y1]))*Dm(p,q)));
end
end
Hi=Ht{1};
for m=2:1:numel(Ht)
Hi=Hi+vpa(Ht{m},3);
end
H=integral(Hi,w1,w2,"ArrayValued",true) integral MATLAB Answers — New Questions
How to import JPK force maps?
Hello,
I am trying to import force maps data from JPK and I could not find any clue on how to begin. Could anyone help me with how I could import raw data from force map files? Any hints and ideas are appriciated. My plan is to fit the data myself in Matlab as the available programs do not offer good fitting methods. I have compressed a JPK force map file in .zip, so I could attach it here.Hello,
I am trying to import force maps data from JPK and I could not find any clue on how to begin. Could anyone help me with how I could import raw data from force map files? Any hints and ideas are appriciated. My plan is to fit the data myself in Matlab as the available programs do not offer good fitting methods. I have compressed a JPK force map file in .zip, so I could attach it here. Hello,
I am trying to import force maps data from JPK and I could not find any clue on how to begin. Could anyone help me with how I could import raw data from force map files? Any hints and ideas are appriciated. My plan is to fit the data myself in Matlab as the available programs do not offer good fitting methods. I have compressed a JPK force map file in .zip, so I could attach it here. afm, jpk, force maps, import jpk force maps MATLAB Answers — New Questions
How can I identify and fill outliers in a 2d matrix?
Hello,
I am wondering if there is a function to identify and fill outliers in a 2d matrix. I know that the filloutliers function does work on a matrix, but it only works on each column separately. I am hoping to look at outliers in both directions.
There is a function fillmissing2 that does exactly this, but for missing values rather than outliers. Does anyone know if there is such a function? Or perhaps a workaround?
Thanks in advance,
SeanHello,
I am wondering if there is a function to identify and fill outliers in a 2d matrix. I know that the filloutliers function does work on a matrix, but it only works on each column separately. I am hoping to look at outliers in both directions.
There is a function fillmissing2 that does exactly this, but for missing values rather than outliers. Does anyone know if there is such a function? Or perhaps a workaround?
Thanks in advance,
Sean Hello,
I am wondering if there is a function to identify and fill outliers in a 2d matrix. I know that the filloutliers function does work on a matrix, but it only works on each column separately. I am hoping to look at outliers in both directions.
There is a function fillmissing2 that does exactly this, but for missing values rather than outliers. Does anyone know if there is such a function? Or perhaps a workaround?
Thanks in advance,
Sean filloutliers, matrix, interpolation MATLAB Answers — New Questions
Invalid Parameter Name: EdgeColor
Hi all,
I’m trying to set the edgecolor parameter to interp for a hist3 plot. But MATLAB keeps giving me an invalid parameter error on edgecolor. It is in the documentation as a valid parameter and as far as I can tell I’m using the latest version of MATLAB: R2024a Update 2. Another strange thing is that even though I get the error message in the Command Window. The figure that is generated does successfully change the edge colors. It seems like MATLAB is doing what I expected but giving an error message for no apparent reason.
I’ve included my implementation and error message for reference.
hist3(X,[250 250],"EdgeColor","interp","CdataMode","auto");
Error using internal.stats.parseArgs (line 43)
Invalid parameter name: EdgeColor.
Error in hist3 (line 278)
[cdatamode,facecolor,~] = internal.stats.parseArgs(plnames,pldflts,plotArgs{:});
Error in Heatmap_test (line 26)
hist3(X,[250 250],"EdgeColor","interp","CdataMode","auto");Hi all,
I’m trying to set the edgecolor parameter to interp for a hist3 plot. But MATLAB keeps giving me an invalid parameter error on edgecolor. It is in the documentation as a valid parameter and as far as I can tell I’m using the latest version of MATLAB: R2024a Update 2. Another strange thing is that even though I get the error message in the Command Window. The figure that is generated does successfully change the edge colors. It seems like MATLAB is doing what I expected but giving an error message for no apparent reason.
I’ve included my implementation and error message for reference.
hist3(X,[250 250],"EdgeColor","interp","CdataMode","auto");
Error using internal.stats.parseArgs (line 43)
Invalid parameter name: EdgeColor.
Error in hist3 (line 278)
[cdatamode,facecolor,~] = internal.stats.parseArgs(plnames,pldflts,plotArgs{:});
Error in Heatmap_test (line 26)
hist3(X,[250 250],"EdgeColor","interp","CdataMode","auto"); Hi all,
I’m trying to set the edgecolor parameter to interp for a hist3 plot. But MATLAB keeps giving me an invalid parameter error on edgecolor. It is in the documentation as a valid parameter and as far as I can tell I’m using the latest version of MATLAB: R2024a Update 2. Another strange thing is that even though I get the error message in the Command Window. The figure that is generated does successfully change the edge colors. It seems like MATLAB is doing what I expected but giving an error message for no apparent reason.
I’ve included my implementation and error message for reference.
hist3(X,[250 250],"EdgeColor","interp","CdataMode","auto");
Error using internal.stats.parseArgs (line 43)
Invalid parameter name: EdgeColor.
Error in hist3 (line 278)
[cdatamode,facecolor,~] = internal.stats.parseArgs(plnames,pldflts,plotArgs{:});
Error in Heatmap_test (line 26)
hist3(X,[250 250],"EdgeColor","interp","CdataMode","auto"); histogram, plotting, error MATLAB Answers — New Questions
solving linear system with decomposition(A,’qr’) and qr(A) produce different results
load post.mat
x1 = decomposition(CA,’qr’)b_f;
[qq2,rr2,pp2] = qr(CA);
x2= pp2 * (rr2(qq2’*b_f));
[qq3,rr3,pp3] = qr(CA,"econ","vector");
x3(pp3,:) = rr3(qq3’*b_f);
any(x1-x2~=0)
any(x3-x2~=0)
I know that the CA matrix is ill-conditioned. But that doesn’t explain the difference in solution, right?
Also, solving the system using decomposition(CA,’lu’) and lu(CA) produce the same results. So why not the ‘qr’ pair?load post.mat
x1 = decomposition(CA,’qr’)b_f;
[qq2,rr2,pp2] = qr(CA);
x2= pp2 * (rr2(qq2’*b_f));
[qq3,rr3,pp3] = qr(CA,"econ","vector");
x3(pp3,:) = rr3(qq3’*b_f);
any(x1-x2~=0)
any(x3-x2~=0)
I know that the CA matrix is ill-conditioned. But that doesn’t explain the difference in solution, right?
Also, solving the system using decomposition(CA,’lu’) and lu(CA) produce the same results. So why not the ‘qr’ pair? load post.mat
x1 = decomposition(CA,’qr’)b_f;
[qq2,rr2,pp2] = qr(CA);
x2= pp2 * (rr2(qq2’*b_f));
[qq3,rr3,pp3] = qr(CA,"econ","vector");
x3(pp3,:) = rr3(qq3’*b_f);
any(x1-x2~=0)
any(x3-x2~=0)
I know that the CA matrix is ill-conditioned. But that doesn’t explain the difference in solution, right?
Also, solving the system using decomposition(CA,’lu’) and lu(CA) produce the same results. So why not the ‘qr’ pair? qr decomposition, linear algebra, linear system MATLAB Answers — New Questions
Reset to original view for UIAxes control in AppDesigner programmatically
Hello,
I am trying to programmatically restore the zoom for original view for UIAxes compoinent in AppDesigner.
I’d like to achieve the same as clicking on the ‘house’ icon at the zoom controls.
Does anyone know how to do this?
–HanHello,
I am trying to programmatically restore the zoom for original view for UIAxes compoinent in AppDesigner.
I’d like to achieve the same as clicking on the ‘house’ icon at the zoom controls.
Does anyone know how to do this?
–Han Hello,
I am trying to programmatically restore the zoom for original view for UIAxes compoinent in AppDesigner.
I’d like to achieve the same as clicking on the ‘house’ icon at the zoom controls.
Does anyone know how to do this?
–Han appdesigner, uiaxes MATLAB Answers — New Questions