Category: Matlab
Category Archives: Matlab
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
I want model a datacenter load from time series power consumption and then connecting it to AC distribution three phase system
Problem I am facing is when I use importedin MATlab and model it as a load using controlled current source and then adding an inverter , my swing bus (From IEEE 13 bus test system) is having Dc bias/ offset instead of balance volatges. I am trying to analyze transient behaviour dueto sudden high current requirement. Please guide why I am getting this problem.Problem I am facing is when I use importedin MATlab and model it as a load using controlled current source and then adding an inverter , my swing bus (From IEEE 13 bus test system) is having Dc bias/ offset instead of balance volatges. I am trying to analyze transient behaviour dueto sudden high current requirement. Please guide why I am getting this problem. Problem I am facing is when I use importedin MATlab and model it as a load using controlled current source and then adding an inverter , my swing bus (From IEEE 13 bus test system) is having Dc bias/ offset instead of balance volatges. I am trying to analyze transient behaviour dueto sudden high current requirement. Please guide why I am getting this problem. load modelling, simulink, ieee 13 bus MATLAB Answers — New Questions
What is the setting in Production Server for auto deployment and how do I set this up?
I could not find a place in Settings section in the Production Sever Dashboard to enable or disable auto deployment, and if I need to add the options through advanced section, what I should put there? Do I need to restart the server/instance after I add the auto deployment configuration?I could not find a place in Settings section in the Production Sever Dashboard to enable or disable auto deployment, and if I need to add the options through advanced section, what I should put there? Do I need to restart the server/instance after I add the auto deployment configuration? I could not find a place in Settings section in the Production Sever Dashboard to enable or disable auto deployment, and if I need to add the options through advanced section, what I should put there? Do I need to restart the server/instance after I add the auto deployment configuration? production server, configuration, auto deployment MATLAB Answers — New Questions
Examples missing from requirements toolbox installation
I am trying to open the "Link test case reqs Example" with the command openExample(‘slrequirements/LinkTestCaseReqsExample’), but the only examples I have installed are "ImportAndEditRequiermentsWordExample" & "VerifyAShortestPathAlgorithmExample". There should be way more than 2 according to the doccumentation.I am trying to open the "Link test case reqs Example" with the command openExample(‘slrequirements/LinkTestCaseReqsExample’), but the only examples I have installed are "ImportAndEditRequiermentsWordExample" & "VerifyAShortestPathAlgorithmExample". There should be way more than 2 according to the doccumentation. I am trying to open the "Link test case reqs Example" with the command openExample(‘slrequirements/LinkTestCaseReqsExample’), but the only examples I have installed are "ImportAndEditRequiermentsWordExample" & "VerifyAShortestPathAlgorithmExample". There should be way more than 2 according to the doccumentation. requirements toolbox, examples MATLAB Answers — New Questions
Accessing Pixhawk 6x parameters when building firmware for SRXL2 connection
I am attempting to get the Pixhawk 6x to receive data from a new spektrum receiver that utilizes SRXL2, the process required for getting the SRXL2 protocol to work involves setting certain parameters to different values, namely:
Set SERIAL4_PROTOCOL = 23
Set SERIAL4_OPTIONS = 4
Set RSSI_TYPE = 3
However, when looking at the parameters avaialble in Qground control or mission planner, these parameters are not present. Additionally, there seems to be some kind of text file called uart.txt that the serial parameters are attempting to read from but it detects nothing when loading. Is there any way of adding these parameters to the pixhawk during the firmware build process? Or is there a specific means of configuring the TELEM2 port for a true UART connection. As this is the only way I can get the SRXL2 to connect to the pixhawk when it is running a simulink model (fmu_v6x_fixedwing).I am attempting to get the Pixhawk 6x to receive data from a new spektrum receiver that utilizes SRXL2, the process required for getting the SRXL2 protocol to work involves setting certain parameters to different values, namely:
Set SERIAL4_PROTOCOL = 23
Set SERIAL4_OPTIONS = 4
Set RSSI_TYPE = 3
However, when looking at the parameters avaialble in Qground control or mission planner, these parameters are not present. Additionally, there seems to be some kind of text file called uart.txt that the serial parameters are attempting to read from but it detects nothing when loading. Is there any way of adding these parameters to the pixhawk during the firmware build process? Or is there a specific means of configuring the TELEM2 port for a true UART connection. As this is the only way I can get the SRXL2 to connect to the pixhawk when it is running a simulink model (fmu_v6x_fixedwing). I am attempting to get the Pixhawk 6x to receive data from a new spektrum receiver that utilizes SRXL2, the process required for getting the SRXL2 protocol to work involves setting certain parameters to different values, namely:
Set SERIAL4_PROTOCOL = 23
Set SERIAL4_OPTIONS = 4
Set RSSI_TYPE = 3
However, when looking at the parameters avaialble in Qground control or mission planner, these parameters are not present. Additionally, there seems to be some kind of text file called uart.txt that the serial parameters are attempting to read from but it detects nothing when loading. Is there any way of adding these parameters to the pixhawk during the firmware build process? Or is there a specific means of configuring the TELEM2 port for a true UART connection. As this is the only way I can get the SRXL2 to connect to the pixhawk when it is running a simulink model (fmu_v6x_fixedwing). simulink, pixhawk, uav toolbox, pixhawk6x, uart, rcin MATLAB Answers — New Questions
Publishing multiple graphs without using a subplot function
How do you publish multiple graphs independently without putting all of them in a subplot?How do you publish multiple graphs independently without putting all of them in a subplot? How do you publish multiple graphs independently without putting all of them in a subplot? graph, subplot, publish MATLAB Answers — New Questions
Numerical method of the “fimplicit” function
Hello, does anyone know what kind of numerical methods are used in the "fimplicit" function? I cannot find any information about this. Thank you!Hello, does anyone know what kind of numerical methods are used in the "fimplicit" function? I cannot find any information about this. Thank you! Hello, does anyone know what kind of numerical methods are used in the "fimplicit" function? I cannot find any information about this. Thank you! fimplicit, numerical method MATLAB Answers — New Questions
How I organize and insert NIR dataset for Classification Learner.
Hello,
I currently research the field of near-infrared spectroscopy (NIR), mainly in the analysis of the spectra of polymeric materials. I would like to make a system for classifying these spectra by machine learning. Literature indicates the APP Classification Leaner and its models to perform the training of the spectra. However, I’m having trouble inserting the spectra sheet (containing wavelength and absorbance values). Being new to Matlab, I don’t know how to organize these spreadsheets with different values, because the wavelength is constant for the different samples, but the absorbance varies for them. My idea is to classify the spectra for the different materials. How could I organize the spreadsheet and develop the training?
If anyone can help me with a tutorial or quick step by step, I would be extremely grateful.
Thanks.Hello,
I currently research the field of near-infrared spectroscopy (NIR), mainly in the analysis of the spectra of polymeric materials. I would like to make a system for classifying these spectra by machine learning. Literature indicates the APP Classification Leaner and its models to perform the training of the spectra. However, I’m having trouble inserting the spectra sheet (containing wavelength and absorbance values). Being new to Matlab, I don’t know how to organize these spreadsheets with different values, because the wavelength is constant for the different samples, but the absorbance varies for them. My idea is to classify the spectra for the different materials. How could I organize the spreadsheet and develop the training?
If anyone can help me with a tutorial or quick step by step, I would be extremely grateful.
Thanks. Hello,
I currently research the field of near-infrared spectroscopy (NIR), mainly in the analysis of the spectra of polymeric materials. I would like to make a system for classifying these spectra by machine learning. Literature indicates the APP Classification Leaner and its models to perform the training of the spectra. However, I’m having trouble inserting the spectra sheet (containing wavelength and absorbance values). Being new to Matlab, I don’t know how to organize these spreadsheets with different values, because the wavelength is constant for the different samples, but the absorbance varies for them. My idea is to classify the spectra for the different materials. How could I organize the spreadsheet and develop the training?
If anyone can help me with a tutorial or quick step by step, I would be extremely grateful.
Thanks. nir, classification learner MATLAB Answers — New Questions
how to generate correct logical mask of the size of shape file?
i am using following code to generate logical mask
function croppedimg = cropimage(data, R, shapefile)
% Load the shapefile and retrieve its info
S = shaperead(shapefile);
% Shapefile projections
info = shapeinfo(shapefile);
crs = info.CoordinateReferenceSystem;
[S.lon,S.lat] = projinv(crs,S.X,S.Y);
% read and reproject image file
p = R.ProjectedCRS;
[x,y] = worldGrid(R);
[lon,lat] = projinv(p,x,y);
% Create a logical mask
% Approach 1: Using ‘inpolygon’ function
xq = lon(:);
yq = lat(:);
in = inpolygon(xq,yq,S.lon,S.lat);
logical_mask = reshape(in,size(lon));
% Debugging: Display the logical mask summary
disp([‘Total number of pixels inside polygon: ‘, num2str(numel(logical_mask))]);
disp([‘Total number of pixels inside image: ‘, num2str(numel(data))]);
However it is showing the
Total number of pixels inside polygon: 16982229
Total number of pixels inside image: 16982229
please suggest me how to create correct logical mask of the size of shape file.
kuldeepi am using following code to generate logical mask
function croppedimg = cropimage(data, R, shapefile)
% Load the shapefile and retrieve its info
S = shaperead(shapefile);
% Shapefile projections
info = shapeinfo(shapefile);
crs = info.CoordinateReferenceSystem;
[S.lon,S.lat] = projinv(crs,S.X,S.Y);
% read and reproject image file
p = R.ProjectedCRS;
[x,y] = worldGrid(R);
[lon,lat] = projinv(p,x,y);
% Create a logical mask
% Approach 1: Using ‘inpolygon’ function
xq = lon(:);
yq = lat(:);
in = inpolygon(xq,yq,S.lon,S.lat);
logical_mask = reshape(in,size(lon));
% Debugging: Display the logical mask summary
disp([‘Total number of pixels inside polygon: ‘, num2str(numel(logical_mask))]);
disp([‘Total number of pixels inside image: ‘, num2str(numel(data))]);
However it is showing the
Total number of pixels inside polygon: 16982229
Total number of pixels inside image: 16982229
please suggest me how to create correct logical mask of the size of shape file.
kuldeep i am using following code to generate logical mask
function croppedimg = cropimage(data, R, shapefile)
% Load the shapefile and retrieve its info
S = shaperead(shapefile);
% Shapefile projections
info = shapeinfo(shapefile);
crs = info.CoordinateReferenceSystem;
[S.lon,S.lat] = projinv(crs,S.X,S.Y);
% read and reproject image file
p = R.ProjectedCRS;
[x,y] = worldGrid(R);
[lon,lat] = projinv(p,x,y);
% Create a logical mask
% Approach 1: Using ‘inpolygon’ function
xq = lon(:);
yq = lat(:);
in = inpolygon(xq,yq,S.lon,S.lat);
logical_mask = reshape(in,size(lon));
% Debugging: Display the logical mask summary
disp([‘Total number of pixels inside polygon: ‘, num2str(numel(logical_mask))]);
disp([‘Total number of pixels inside image: ‘, num2str(numel(data))]);
However it is showing the
Total number of pixels inside polygon: 16982229
Total number of pixels inside image: 16982229
please suggest me how to create correct logical mask of the size of shape file.
kuldeep how to generate correct logical mask ? MATLAB Answers — New Questions
Simulink filter using frequency response transfer function
Hi,
My main problem is this: I’m building a fiber optical communication system using simulink.
As a source, I use a bernoulli generator, then this signal runs to a low pass filter and the exit is the signal equivalent to a signal that comes off a led, so the emission part is done.
The problems begins at the transmission channel. I want to do a filter that simulates the dispersion effect in the fiber (only chromatic dispersion), but I don’t know how. I only have a transfer functions like exp(-j*alpha*f.^2) and I don’t know what to do with this. What’s the right procedure to implement this kind of t.f. in a analog filter at the simulink?
Any help is welcome.
Kind regardsHi,
My main problem is this: I’m building a fiber optical communication system using simulink.
As a source, I use a bernoulli generator, then this signal runs to a low pass filter and the exit is the signal equivalent to a signal that comes off a led, so the emission part is done.
The problems begins at the transmission channel. I want to do a filter that simulates the dispersion effect in the fiber (only chromatic dispersion), but I don’t know how. I only have a transfer functions like exp(-j*alpha*f.^2) and I don’t know what to do with this. What’s the right procedure to implement this kind of t.f. in a analog filter at the simulink?
Any help is welcome.
Kind regards Hi,
My main problem is this: I’m building a fiber optical communication system using simulink.
As a source, I use a bernoulli generator, then this signal runs to a low pass filter and the exit is the signal equivalent to a signal that comes off a led, so the emission part is done.
The problems begins at the transmission channel. I want to do a filter that simulates the dispersion effect in the fiber (only chromatic dispersion), but I don’t know how. I only have a transfer functions like exp(-j*alpha*f.^2) and I don’t know what to do with this. What’s the right procedure to implement this kind of t.f. in a analog filter at the simulink?
Any help is welcome.
Kind regards simulink, optical dispersion MATLAB Answers — New Questions
Why does App Designer include the full file path when packaging external helper functions?
I am trying to create a GUI for some existing code I wrote using the MATLAB App Designer. The app relies on some external helper functions that I wrote in MATLAB program files and they are correctly identified as necessary to include; however, when packaged it includes the entire file path of the matlab function files within the installed package. This means that after installing the app, for example, tallySum.m ends up stored in "/Users/rhysg/Library/Application Support/MathWorks/MATLAB Add-Ons/Apps/NNB_GUI/Users/rhysg/Documents/YPGRA/TIRF_ProcessingCode/tallySum.m" instead of just placing it in "/Users/rhysg/Library/Application Support/MathWorks/MATLAB Add-Ons/Apps/NNB_GUI/tallySum.m"
This doesn’t cause functional problems but it does not seem intended and I was wondering if it could be avoided. Other than copying all the functions directly into the app is there a way to fix this? Is there a reason it functions in this way? Is there somewhere else to look for information on this?
Thanks in advance.I am trying to create a GUI for some existing code I wrote using the MATLAB App Designer. The app relies on some external helper functions that I wrote in MATLAB program files and they are correctly identified as necessary to include; however, when packaged it includes the entire file path of the matlab function files within the installed package. This means that after installing the app, for example, tallySum.m ends up stored in "/Users/rhysg/Library/Application Support/MathWorks/MATLAB Add-Ons/Apps/NNB_GUI/Users/rhysg/Documents/YPGRA/TIRF_ProcessingCode/tallySum.m" instead of just placing it in "/Users/rhysg/Library/Application Support/MathWorks/MATLAB Add-Ons/Apps/NNB_GUI/tallySum.m"
This doesn’t cause functional problems but it does not seem intended and I was wondering if it could be avoided. Other than copying all the functions directly into the app is there a way to fix this? Is there a reason it functions in this way? Is there somewhere else to look for information on this?
Thanks in advance. I am trying to create a GUI for some existing code I wrote using the MATLAB App Designer. The app relies on some external helper functions that I wrote in MATLAB program files and they are correctly identified as necessary to include; however, when packaged it includes the entire file path of the matlab function files within the installed package. This means that after installing the app, for example, tallySum.m ends up stored in "/Users/rhysg/Library/Application Support/MathWorks/MATLAB Add-Ons/Apps/NNB_GUI/Users/rhysg/Documents/YPGRA/TIRF_ProcessingCode/tallySum.m" instead of just placing it in "/Users/rhysg/Library/Application Support/MathWorks/MATLAB Add-Ons/Apps/NNB_GUI/tallySum.m"
This doesn’t cause functional problems but it does not seem intended and I was wondering if it could be avoided. Other than copying all the functions directly into the app is there a way to fix this? Is there a reason it functions in this way? Is there somewhere else to look for information on this?
Thanks in advance. app designer MATLAB Answers — New Questions
How to insert an image into a specific Excel cell?
In Excel, I can place an image into a specific cell using Insert -> Pictures -> Place in Cell; this inserts the image into the cell, not floating over the cell. Can the same thing be done from MATLAB using ActiveX? Note I already have working code to insert a floating image in any desired location. What I really need to do is to insert it into a cell of my choosing.In Excel, I can place an image into a specific cell using Insert -> Pictures -> Place in Cell; this inserts the image into the cell, not floating over the cell. Can the same thing be done from MATLAB using ActiveX? Note I already have working code to insert a floating image in any desired location. What I really need to do is to insert it into a cell of my choosing. In Excel, I can place an image into a specific cell using Insert -> Pictures -> Place in Cell; this inserts the image into the cell, not floating over the cell. Can the same thing be done from MATLAB using ActiveX? Note I already have working code to insert a floating image in any desired location. What I really need to do is to insert it into a cell of my choosing. insert image, excel MATLAB Answers — New Questions
identify model parameters and data (g = Gm).
I have a problem, namely to identify model parameters and data (g = Gm).
I’ve done it in my notebook, but I want to write a matlab script for this and I’m struggling on how to write the matrix G the right way in matlab.
This is how I write G in my notebook:
1111000000000000
0000111100000000
0000000011110000
0000000000001111
1000100010001000
0100010001000100
0010001000100010
0001000100010001I have a problem, namely to identify model parameters and data (g = Gm).
I’ve done it in my notebook, but I want to write a matlab script for this and I’m struggling on how to write the matrix G the right way in matlab.
This is how I write G in my notebook:
1111000000000000
0000111100000000
0000000011110000
0000000000001111
1000100010001000
0100010001000100
0010001000100010
0001000100010001 I have a problem, namely to identify model parameters and data (g = Gm).
I’ve done it in my notebook, but I want to write a matlab script for this and I’m struggling on how to write the matrix G the right way in matlab.
This is how I write G in my notebook:
1111000000000000
0000111100000000
0000000011110000
0000000000001111
1000100010001000
0100010001000100
0010001000100010
0001000100010001 #help MATLAB Answers — New Questions
Fit a custom made function to a certain trend within data from a matrix
Dear all,
I have been struggling for a while with the two issues that I show you below.
I have a matrix which represents the image of a pixelated neutron detector. The units of such a matrix is Count/minute. If I plot the matrix with the command surface(X, Y, Z), being Z the matrix, I get the following figure:
In this figure we can see two different trends: the x=y line (plus its width), which is what we call the "Specular Ridge", and a tiny contribution given by the white dashed line, which is what we call the "Zemann Splitting". The Zemann splitting is given by the equation y = sqrt(x^2 – (1.47e-7*H*L^2)), where H is the magnetic field and L is the wavelength of the nuetrons (5.183 AA in my case).
I would like to find the optimum H which fits best to the data inside the red circle by using the above mentioned equation (H should be something like 6-7). And later I would like to make a ROI (Region Of Interest) to count how many counts lay within such area.
I have attached the matrix (file 00607_UD_subplot.txt) and X and Y coordinates (files 00607_UD_xcoordinates.txt and 00607_UD_ycoordinates.txt).
The code to visualize the figure is the following:
A = load(‘00607_UD_subplot.txt’);
X = load(‘00607_UD_xcoordinates.txt’);
Y = load(‘00607_UD_ycoordinates.txt’);
surface(X, Y, A)
axis square
colormap(map);
caxis([5e-4 100])
set(gca,’colorscale’,’log’)
hold on
plot(X, sqrt((X.^2) – (1.47e-7*6.5*5.183^2)), ‘Color’,’white’,’LineStyle’,’–‘, ‘LineWidth’, 2)
xlabel(‘alpha_{i} [rad]’, ‘fontsize’, 18);
ylabel(‘alpha_{f} [rad]’, ‘fontsize’, 18);
cb1 = colorbar;
cb1.Label.String = ‘Neutron Intensity (CTS/MIN)’;
cb1.FontSize = 16;
cb1.Label.FontSize = 20;
cb1.LineWidth = 1.5;
Any help / suggestion would be helpful and very welcomedl!!!
Cheers,
Jose.Dear all,
I have been struggling for a while with the two issues that I show you below.
I have a matrix which represents the image of a pixelated neutron detector. The units of such a matrix is Count/minute. If I plot the matrix with the command surface(X, Y, Z), being Z the matrix, I get the following figure:
In this figure we can see two different trends: the x=y line (plus its width), which is what we call the "Specular Ridge", and a tiny contribution given by the white dashed line, which is what we call the "Zemann Splitting". The Zemann splitting is given by the equation y = sqrt(x^2 – (1.47e-7*H*L^2)), where H is the magnetic field and L is the wavelength of the nuetrons (5.183 AA in my case).
I would like to find the optimum H which fits best to the data inside the red circle by using the above mentioned equation (H should be something like 6-7). And later I would like to make a ROI (Region Of Interest) to count how many counts lay within such area.
I have attached the matrix (file 00607_UD_subplot.txt) and X and Y coordinates (files 00607_UD_xcoordinates.txt and 00607_UD_ycoordinates.txt).
The code to visualize the figure is the following:
A = load(‘00607_UD_subplot.txt’);
X = load(‘00607_UD_xcoordinates.txt’);
Y = load(‘00607_UD_ycoordinates.txt’);
surface(X, Y, A)
axis square
colormap(map);
caxis([5e-4 100])
set(gca,’colorscale’,’log’)
hold on
plot(X, sqrt((X.^2) – (1.47e-7*6.5*5.183^2)), ‘Color’,’white’,’LineStyle’,’–‘, ‘LineWidth’, 2)
xlabel(‘alpha_{i} [rad]’, ‘fontsize’, 18);
ylabel(‘alpha_{f} [rad]’, ‘fontsize’, 18);
cb1 = colorbar;
cb1.Label.String = ‘Neutron Intensity (CTS/MIN)’;
cb1.FontSize = 16;
cb1.Label.FontSize = 20;
cb1.LineWidth = 1.5;
Any help / suggestion would be helpful and very welcomedl!!!
Cheers,
Jose. Dear all,
I have been struggling for a while with the two issues that I show you below.
I have a matrix which represents the image of a pixelated neutron detector. The units of such a matrix is Count/minute. If I plot the matrix with the command surface(X, Y, Z), being Z the matrix, I get the following figure:
In this figure we can see two different trends: the x=y line (plus its width), which is what we call the "Specular Ridge", and a tiny contribution given by the white dashed line, which is what we call the "Zemann Splitting". The Zemann splitting is given by the equation y = sqrt(x^2 – (1.47e-7*H*L^2)), where H is the magnetic field and L is the wavelength of the nuetrons (5.183 AA in my case).
I would like to find the optimum H which fits best to the data inside the red circle by using the above mentioned equation (H should be something like 6-7). And later I would like to make a ROI (Region Of Interest) to count how many counts lay within such area.
I have attached the matrix (file 00607_UD_subplot.txt) and X and Y coordinates (files 00607_UD_xcoordinates.txt and 00607_UD_ycoordinates.txt).
The code to visualize the figure is the following:
A = load(‘00607_UD_subplot.txt’);
X = load(‘00607_UD_xcoordinates.txt’);
Y = load(‘00607_UD_ycoordinates.txt’);
surface(X, Y, A)
axis square
colormap(map);
caxis([5e-4 100])
set(gca,’colorscale’,’log’)
hold on
plot(X, sqrt((X.^2) – (1.47e-7*6.5*5.183^2)), ‘Color’,’white’,’LineStyle’,’–‘, ‘LineWidth’, 2)
xlabel(‘alpha_{i} [rad]’, ‘fontsize’, 18);
ylabel(‘alpha_{f} [rad]’, ‘fontsize’, 18);
cb1 = colorbar;
cb1.Label.String = ‘Neutron Intensity (CTS/MIN)’;
cb1.FontSize = 16;
cb1.Label.FontSize = 20;
cb1.LineWidth = 1.5;
Any help / suggestion would be helpful and very welcomedl!!!
Cheers,
Jose. curve fitting, region of interest MATLAB Answers — New Questions
Enter table with conditional limits and able to interpolate
I would like to enter the following numerical table with conditional limits and be able to interpolate within the values provided in the table. I was able to enter the rows x columns but I do not know what can I do for those values that are less than or larger than. How can <= or >= be taken care of? I believe interp2 should be used to find intermediate values for lets say h/L=12 degrees and h/L =0.35 for example. Please advise.I would like to enter the following numerical table with conditional limits and be able to interpolate within the values provided in the table. I was able to enter the rows x columns but I do not know what can I do for those values that are less than or larger than. How can <= or >= be taken care of? I believe interp2 should be used to find intermediate values for lets say h/L=12 degrees and h/L =0.35 for example. Please advise. I would like to enter the following numerical table with conditional limits and be able to interpolate within the values provided in the table. I was able to enter the rows x columns but I do not know what can I do for those values that are less than or larger than. How can <= or >= be taken care of? I believe interp2 should be used to find intermediate values for lets say h/L=12 degrees and h/L =0.35 for example. Please advise. interpolation and table question MATLAB Answers — New Questions
Eventfilters with durations return wrong (amount of) rows?
Hi all, I have a question that’s either a case of "am I not understanding this right?" or a bug in eventfilters.
I’ve noticed 2 things: 1) event filters with durations seem to return the rows after the start of events, and 2) scaling the duration of events does not result in the expected scaling of the number of rows filtered.
For background, in reality I’m using this to mark the edges of TTL-pulses in datasets, but I made an example below that I think illustrates my point.
Running the following code:
% Create a 5s timetable with mock data.
test_table = timetable(seconds(linspace(1/1000, 5, 5000)).’, linspace(0, 1, 5000).’);
% Create an eventtable with 3 events at random time points and a duration
% equal to the table timestep.
test_times = seconds([1.101, 2.2, 3]);
labels = ["rising", "rising", "falling"];
delta_t = test_table.Properties.TimeStep;
lengths = repmat(1*delta_t, 1, 3);
test_events = eventtable(test_times, EventLabels = labels, EventLengths = lengths);
% Associate events with timetable.
test_table.Properties.Events = test_events;
% Create a filter to determine the time of the rising edges.
test_filter = eventfilter("rising");
test_rows = test_table(test_filter, :);
% Display number of rows returned by the filter.
disp(height(test_rows));
% Display the times of the filtered rows.
disp(test_rows.Time);
So here I’m making a mock timetable of 5 seconds at 1000 Hz, with mock data in it, and 3 time events: two rising edges, and one falling edge. Each event is given a length of 1/1000s or 1 ms, which is equal to the timestep of the table. Then, I create an eventfilter to extract the rows of the time table at these edges.
Issue 1
The filter returns 2 rows as expected. However, the row times are 1.102 and 2.201, which are the row times after the rows in which the events begin according to the event table. This seems at odds with the description in the documentation for eventtable, which says that "Interval events happen during intervals that start at event times and include all times up to, but not including, the times at the end of the events." (emphasis mine). So shouldn’t these timed events return the row times 1.101 and 2.200 seconds?
As an aside, removing the EventLengths from the eventtable constructor returns the correct row times.
Issue 2
Second, for events with lengths larger than a single TimeStep, increasing the duration by a given factor does not always increase the number of returned rows by the same amount.
In this case, if I replace
lengths = repmat(1*delta_t, 1, 3);
with
lengths = repmat(50*delta_t, 1, 3);
and run the code again:
test_events = eventtable(test_times, EventLabels = labels, EventLengths = lengths);
test_table.Properties.Events = test_events;
test_filter = eventfilter("rising");
test_rows = test_table(test_filter, :);
disp(height(test_rows));
the number of filtered rows increases from 2 to 100, as expected.
However, increasing the duration of the events to 100 TimeSteps, changes the number of filtered rows to 199 instead of 200, which is what I was expecting.
lengths = repmat(100*delta_t, 1, 3);
test_events = eventtable(test_times, EventLabels = labels, EventLengths = lengths);
test_table.Properties.Events = test_events;
test_filter = eventfilter("rising");
test_rows = test_table(test_filter, :);
disp(height(test_rows));
This seems odd, given that both 50 and 100 TimeSteps should easily fit within the time vector of the table, are exact multiples of each other, do not overlap with other events and the length was based on the TimeStep property of the table.
I’ve locally tested the script in 2024a, but the code examples above ran in 2024b.Hi all, I have a question that’s either a case of "am I not understanding this right?" or a bug in eventfilters.
I’ve noticed 2 things: 1) event filters with durations seem to return the rows after the start of events, and 2) scaling the duration of events does not result in the expected scaling of the number of rows filtered.
For background, in reality I’m using this to mark the edges of TTL-pulses in datasets, but I made an example below that I think illustrates my point.
Running the following code:
% Create a 5s timetable with mock data.
test_table = timetable(seconds(linspace(1/1000, 5, 5000)).’, linspace(0, 1, 5000).’);
% Create an eventtable with 3 events at random time points and a duration
% equal to the table timestep.
test_times = seconds([1.101, 2.2, 3]);
labels = ["rising", "rising", "falling"];
delta_t = test_table.Properties.TimeStep;
lengths = repmat(1*delta_t, 1, 3);
test_events = eventtable(test_times, EventLabels = labels, EventLengths = lengths);
% Associate events with timetable.
test_table.Properties.Events = test_events;
% Create a filter to determine the time of the rising edges.
test_filter = eventfilter("rising");
test_rows = test_table(test_filter, :);
% Display number of rows returned by the filter.
disp(height(test_rows));
% Display the times of the filtered rows.
disp(test_rows.Time);
So here I’m making a mock timetable of 5 seconds at 1000 Hz, with mock data in it, and 3 time events: two rising edges, and one falling edge. Each event is given a length of 1/1000s or 1 ms, which is equal to the timestep of the table. Then, I create an eventfilter to extract the rows of the time table at these edges.
Issue 1
The filter returns 2 rows as expected. However, the row times are 1.102 and 2.201, which are the row times after the rows in which the events begin according to the event table. This seems at odds with the description in the documentation for eventtable, which says that "Interval events happen during intervals that start at event times and include all times up to, but not including, the times at the end of the events." (emphasis mine). So shouldn’t these timed events return the row times 1.101 and 2.200 seconds?
As an aside, removing the EventLengths from the eventtable constructor returns the correct row times.
Issue 2
Second, for events with lengths larger than a single TimeStep, increasing the duration by a given factor does not always increase the number of returned rows by the same amount.
In this case, if I replace
lengths = repmat(1*delta_t, 1, 3);
with
lengths = repmat(50*delta_t, 1, 3);
and run the code again:
test_events = eventtable(test_times, EventLabels = labels, EventLengths = lengths);
test_table.Properties.Events = test_events;
test_filter = eventfilter("rising");
test_rows = test_table(test_filter, :);
disp(height(test_rows));
the number of filtered rows increases from 2 to 100, as expected.
However, increasing the duration of the events to 100 TimeSteps, changes the number of filtered rows to 199 instead of 200, which is what I was expecting.
lengths = repmat(100*delta_t, 1, 3);
test_events = eventtable(test_times, EventLabels = labels, EventLengths = lengths);
test_table.Properties.Events = test_events;
test_filter = eventfilter("rising");
test_rows = test_table(test_filter, :);
disp(height(test_rows));
This seems odd, given that both 50 and 100 TimeSteps should easily fit within the time vector of the table, are exact multiples of each other, do not overlap with other events and the length was based on the TimeStep property of the table.
I’ve locally tested the script in 2024a, but the code examples above ran in 2024b. Hi all, I have a question that’s either a case of "am I not understanding this right?" or a bug in eventfilters.
I’ve noticed 2 things: 1) event filters with durations seem to return the rows after the start of events, and 2) scaling the duration of events does not result in the expected scaling of the number of rows filtered.
For background, in reality I’m using this to mark the edges of TTL-pulses in datasets, but I made an example below that I think illustrates my point.
Running the following code:
% Create a 5s timetable with mock data.
test_table = timetable(seconds(linspace(1/1000, 5, 5000)).’, linspace(0, 1, 5000).’);
% Create an eventtable with 3 events at random time points and a duration
% equal to the table timestep.
test_times = seconds([1.101, 2.2, 3]);
labels = ["rising", "rising", "falling"];
delta_t = test_table.Properties.TimeStep;
lengths = repmat(1*delta_t, 1, 3);
test_events = eventtable(test_times, EventLabels = labels, EventLengths = lengths);
% Associate events with timetable.
test_table.Properties.Events = test_events;
% Create a filter to determine the time of the rising edges.
test_filter = eventfilter("rising");
test_rows = test_table(test_filter, :);
% Display number of rows returned by the filter.
disp(height(test_rows));
% Display the times of the filtered rows.
disp(test_rows.Time);
So here I’m making a mock timetable of 5 seconds at 1000 Hz, with mock data in it, and 3 time events: two rising edges, and one falling edge. Each event is given a length of 1/1000s or 1 ms, which is equal to the timestep of the table. Then, I create an eventfilter to extract the rows of the time table at these edges.
Issue 1
The filter returns 2 rows as expected. However, the row times are 1.102 and 2.201, which are the row times after the rows in which the events begin according to the event table. This seems at odds with the description in the documentation for eventtable, which says that "Interval events happen during intervals that start at event times and include all times up to, but not including, the times at the end of the events." (emphasis mine). So shouldn’t these timed events return the row times 1.101 and 2.200 seconds?
As an aside, removing the EventLengths from the eventtable constructor returns the correct row times.
Issue 2
Second, for events with lengths larger than a single TimeStep, increasing the duration by a given factor does not always increase the number of returned rows by the same amount.
In this case, if I replace
lengths = repmat(1*delta_t, 1, 3);
with
lengths = repmat(50*delta_t, 1, 3);
and run the code again:
test_events = eventtable(test_times, EventLabels = labels, EventLengths = lengths);
test_table.Properties.Events = test_events;
test_filter = eventfilter("rising");
test_rows = test_table(test_filter, :);
disp(height(test_rows));
the number of filtered rows increases from 2 to 100, as expected.
However, increasing the duration of the events to 100 TimeSteps, changes the number of filtered rows to 199 instead of 200, which is what I was expecting.
lengths = repmat(100*delta_t, 1, 3);
test_events = eventtable(test_times, EventLabels = labels, EventLengths = lengths);
test_table.Properties.Events = test_events;
test_filter = eventfilter("rising");
test_rows = test_table(test_filter, :);
disp(height(test_rows));
This seems odd, given that both 50 and 100 TimeSteps should easily fit within the time vector of the table, are exact multiples of each other, do not overlap with other events and the length was based on the TimeStep property of the table.
I’ve locally tested the script in 2024a, but the code examples above ran in 2024b. time series, eventtable, timetable, matlab, eventfilter MATLAB Answers — New Questions