Tag Archives: matlab
How to improve efficiency of patternsearch function optimization with multiple outputs
I have written a code that uses patternsearch to optimize a complex aircraft geometry for a desired flight condition. The code itself is extremely long, so I’m writing a simpler version below. The function of interest takes multiple geometric variables as inputs, and outputs lift (the objective) and volume (the constraint). I have followed some guides, and have my code setup in a way like this at the moment (this is an extremely simplified version for brevity):
obj = fcn2optimexpr(@lift_fun,x1,x2,x3,x4,x5);
prob = optimproblem("Objective",1/obj);
const1 = fcn2optimexpr(@volume_fun,x1,x2,x3,x4,x5);
prob.Constraints.vol = const1 >= 5;
x0 = [1 2 3 4 5];
[sol] = solve(prob,x0,"Solver","patternsearch","Options",options);
function [lift] = lift_fun(w,n,beta,epsS,p2,p3,Mdesign)
[lift,~] = master_function(x1,x2,x3,x4,x5);
end
function [volume] = volume_fun(w,n,beta,epsS,p2,p3,Mdesign)
[~,volume] = master_function(x1,x2,x3,x4,x5);
end
As I understand it, this code is calling the function ‘master_function’ twice for every optimization loop. This is a problem because this function takes up to a minute to run every time. Because of this I am wondering if it is possible to edit this code so that ‘master_function’ is only called once, providing both the objective and the constraint for the patternsearch optimization? Thank you for your helpI have written a code that uses patternsearch to optimize a complex aircraft geometry for a desired flight condition. The code itself is extremely long, so I’m writing a simpler version below. The function of interest takes multiple geometric variables as inputs, and outputs lift (the objective) and volume (the constraint). I have followed some guides, and have my code setup in a way like this at the moment (this is an extremely simplified version for brevity):
obj = fcn2optimexpr(@lift_fun,x1,x2,x3,x4,x5);
prob = optimproblem("Objective",1/obj);
const1 = fcn2optimexpr(@volume_fun,x1,x2,x3,x4,x5);
prob.Constraints.vol = const1 >= 5;
x0 = [1 2 3 4 5];
[sol] = solve(prob,x0,"Solver","patternsearch","Options",options);
function [lift] = lift_fun(w,n,beta,epsS,p2,p3,Mdesign)
[lift,~] = master_function(x1,x2,x3,x4,x5);
end
function [volume] = volume_fun(w,n,beta,epsS,p2,p3,Mdesign)
[~,volume] = master_function(x1,x2,x3,x4,x5);
end
As I understand it, this code is calling the function ‘master_function’ twice for every optimization loop. This is a problem because this function takes up to a minute to run every time. Because of this I am wondering if it is possible to edit this code so that ‘master_function’ is only called once, providing both the objective and the constraint for the patternsearch optimization? Thank you for your help I have written a code that uses patternsearch to optimize a complex aircraft geometry for a desired flight condition. The code itself is extremely long, so I’m writing a simpler version below. The function of interest takes multiple geometric variables as inputs, and outputs lift (the objective) and volume (the constraint). I have followed some guides, and have my code setup in a way like this at the moment (this is an extremely simplified version for brevity):
obj = fcn2optimexpr(@lift_fun,x1,x2,x3,x4,x5);
prob = optimproblem("Objective",1/obj);
const1 = fcn2optimexpr(@volume_fun,x1,x2,x3,x4,x5);
prob.Constraints.vol = const1 >= 5;
x0 = [1 2 3 4 5];
[sol] = solve(prob,x0,"Solver","patternsearch","Options",options);
function [lift] = lift_fun(w,n,beta,epsS,p2,p3,Mdesign)
[lift,~] = master_function(x1,x2,x3,x4,x5);
end
function [volume] = volume_fun(w,n,beta,epsS,p2,p3,Mdesign)
[~,volume] = master_function(x1,x2,x3,x4,x5);
end
As I understand it, this code is calling the function ‘master_function’ twice for every optimization loop. This is a problem because this function takes up to a minute to run every time. Because of this I am wondering if it is possible to edit this code so that ‘master_function’ is only called once, providing both the objective and the constraint for the patternsearch optimization? Thank you for your help optimization, functions MATLAB Answers — New Questions
how to perform two dimensional deconvolution in matlab?
result2=[600 600] matrix,
frq22=[600 600] matrix,
I have to deconvolve these two matrices.For this I am using the following code but it’s not working.
Img=deconv(result2,frq22,’same’);result2=[600 600] matrix,
frq22=[600 600] matrix,
I have to deconvolve these two matrices.For this I am using the following code but it’s not working.
Img=deconv(result2,frq22,’same’); result2=[600 600] matrix,
frq22=[600 600] matrix,
I have to deconvolve these two matrices.For this I am using the following code but it’s not working.
Img=deconv(result2,frq22,’same’); deconvolution of signals, 2d deconvolution MATLAB Answers — New Questions
How to open a 12-bit .raw image file from Matlab
Hello guys,
Firt timer here asking a question. I have a 12-bit .raw image file save from our experiment – this normall consist of up to 10,000 frames.
I am trying to us matlab to read this .raw file and reconstruct it back into frame images, e.g. Tiff ones. But, as you may expect already, I kept on failing. I have attached a single frame example here.
What I tried is to reconstruct this single frame first.
file=fopen(‘Example.raw’,’r’);
ImgFile=fread(file,’*ubit12′);
Just to read this what I got is a 2621440×1 single array unit 16. My image is 1280×1024, so for some reason I dont know, the element count doubled. I tried some method to pick 1310720 elements out and use reshape to get an image, but never got what I need.
Some assistance here would be greatly appreciated. cheersHello guys,
Firt timer here asking a question. I have a 12-bit .raw image file save from our experiment – this normall consist of up to 10,000 frames.
I am trying to us matlab to read this .raw file and reconstruct it back into frame images, e.g. Tiff ones. But, as you may expect already, I kept on failing. I have attached a single frame example here.
What I tried is to reconstruct this single frame first.
file=fopen(‘Example.raw’,’r’);
ImgFile=fread(file,’*ubit12′);
Just to read this what I got is a 2621440×1 single array unit 16. My image is 1280×1024, so for some reason I dont know, the element count doubled. I tried some method to pick 1310720 elements out and use reshape to get an image, but never got what I need.
Some assistance here would be greatly appreciated. cheers Hello guys,
Firt timer here asking a question. I have a 12-bit .raw image file save from our experiment – this normall consist of up to 10,000 frames.
I am trying to us matlab to read this .raw file and reconstruct it back into frame images, e.g. Tiff ones. But, as you may expect already, I kept on failing. I have attached a single frame example here.
What I tried is to reconstruct this single frame first.
file=fopen(‘Example.raw’,’r’);
ImgFile=fread(file,’*ubit12′);
Just to read this what I got is a 2621440×1 single array unit 16. My image is 1280×1024, so for some reason I dont know, the element count doubled. I tried some method to pick 1310720 elements out and use reshape to get an image, but never got what I need.
Some assistance here would be greatly appreciated. cheers image processing, .raw, image analysis MATLAB Answers — New Questions
How to splice fiber optic?
Optical fiber splicing, also known as optical fiber splicing, is a process in which two separated optical fibers are fused into one by a special equipment, fiber splicing machine. Fiber fusion is not as simple as fusing two bare fibers together as people think, it is a series of meticulous work, very testing the patience and expertise of the operator.
1.What are the advantages of fiber fusion?
(1)The fiber welding loss is small (0.01 to 0.02);
(2)The fused optical fiber is basically not affected by the environment and has low maintenance cost in the later period.
2.What is fiber optic fusion splicer?
Optical fiber splicer is a kind of equipment that fuses two optical fibers together to form a long optical fiber by using high-voltage arc to produce high temperature above 2000℃, so that optical signals can be transferred from one optical fiber to another optical fiber with little loss.
According to different alignment methods, optical fiber fusion splicer can be divided into two categories: cladding alignment and core alignment.
2.1 Cladding alignment
Cladding alignment is the cladding of optical fiber rather than optical fiber. The fiber loss after fusion and splicing is relatively large. It is suitable for short distance transmission, such as optical fiber to the home and other occasions with low requirements, so the price is relatively low.
2.2 Core alignment
The core aligners are equipped with more advanced technology and better performance hardware, which can accurately identify the type of fiber and automatically select the matching welding mode and splice. The welding quality is higher and the loss is lower. It is suitable for all applications of optical fiber welding, so the relative price is higher.
Finally, if you need a core alignment welding machine, then fusion splicer BD-FS-41B is suitable for you, with high welding accuracy, high reliability, military grade, 7 seconds of welding, 18 seconds of heating, cost-effective. If you need a portable machine, I recommend you choose handheld BD-FS-35, 8 second splicing, 30 second heating, easy to use and easy to carry.
3.How to splice fiber optic?
The most efficient way to splice optical fibers is to use an optical fiber splicer. Fusion splicing machine is an automatic machine. You can set your own splicing parameters or use factory-recommended parameters.
Basically, there are nine basic steps to splicing fiber with a splicer.
(1) Firstly, open the fiber Fusion splicer to stand by.
(2) Insert the cooling tree in the back of the heating trough.
(3)Put on the fusion splice protection sleeve.
(4) Peel off the fibers.
Strip off all fiber coating, leaving only 125um of bare fiber, then use 99% isopropyl alcohol to clean the bare fiber.
(5) Cut the fibers.
Open the fiber cleaver pulls the fiber into the fiber cleaver and press the yellow knob in the front to cleave the fiber.
(6)Put the fiber into the fiber holders of the fusion machine.
Press the Start button to start the fusion splicing.
(7) Remove the fiber and reinforce it with a heater.
Take out the optical fiber from the welding machine, put the heat shrink tube into the heater to heat, the heating process is down after hearing the beep, then take out the optical fiber.
(8) Cooling the fiber. Place the heat shrink tube onto the cooling tray to cool down in around 10 to 20 seconds.
(9) Pull out the fiber.
Finally, if you want to know more about this process you can click on the video link below, I hope it helps you.
More information can be found on the website baudcom.Optical fiber splicing, also known as optical fiber splicing, is a process in which two separated optical fibers are fused into one by a special equipment, fiber splicing machine. Fiber fusion is not as simple as fusing two bare fibers together as people think, it is a series of meticulous work, very testing the patience and expertise of the operator.
1.What are the advantages of fiber fusion?
(1)The fiber welding loss is small (0.01 to 0.02);
(2)The fused optical fiber is basically not affected by the environment and has low maintenance cost in the later period.
2.What is fiber optic fusion splicer?
Optical fiber splicer is a kind of equipment that fuses two optical fibers together to form a long optical fiber by using high-voltage arc to produce high temperature above 2000℃, so that optical signals can be transferred from one optical fiber to another optical fiber with little loss.
According to different alignment methods, optical fiber fusion splicer can be divided into two categories: cladding alignment and core alignment.
2.1 Cladding alignment
Cladding alignment is the cladding of optical fiber rather than optical fiber. The fiber loss after fusion and splicing is relatively large. It is suitable for short distance transmission, such as optical fiber to the home and other occasions with low requirements, so the price is relatively low.
2.2 Core alignment
The core aligners are equipped with more advanced technology and better performance hardware, which can accurately identify the type of fiber and automatically select the matching welding mode and splice. The welding quality is higher and the loss is lower. It is suitable for all applications of optical fiber welding, so the relative price is higher.
Finally, if you need a core alignment welding machine, then fusion splicer BD-FS-41B is suitable for you, with high welding accuracy, high reliability, military grade, 7 seconds of welding, 18 seconds of heating, cost-effective. If you need a portable machine, I recommend you choose handheld BD-FS-35, 8 second splicing, 30 second heating, easy to use and easy to carry.
3.How to splice fiber optic?
The most efficient way to splice optical fibers is to use an optical fiber splicer. Fusion splicing machine is an automatic machine. You can set your own splicing parameters or use factory-recommended parameters.
Basically, there are nine basic steps to splicing fiber with a splicer.
(1) Firstly, open the fiber Fusion splicer to stand by.
(2) Insert the cooling tree in the back of the heating trough.
(3)Put on the fusion splice protection sleeve.
(4) Peel off the fibers.
Strip off all fiber coating, leaving only 125um of bare fiber, then use 99% isopropyl alcohol to clean the bare fiber.
(5) Cut the fibers.
Open the fiber cleaver pulls the fiber into the fiber cleaver and press the yellow knob in the front to cleave the fiber.
(6)Put the fiber into the fiber holders of the fusion machine.
Press the Start button to start the fusion splicing.
(7) Remove the fiber and reinforce it with a heater.
Take out the optical fiber from the welding machine, put the heat shrink tube into the heater to heat, the heating process is down after hearing the beep, then take out the optical fiber.
(8) Cooling the fiber. Place the heat shrink tube onto the cooling tray to cool down in around 10 to 20 seconds.
(9) Pull out the fiber.
Finally, if you want to know more about this process you can click on the video link below, I hope it helps you.
More information can be found on the website baudcom. Optical fiber splicing, also known as optical fiber splicing, is a process in which two separated optical fibers are fused into one by a special equipment, fiber splicing machine. Fiber fusion is not as simple as fusing two bare fibers together as people think, it is a series of meticulous work, very testing the patience and expertise of the operator.
1.What are the advantages of fiber fusion?
(1)The fiber welding loss is small (0.01 to 0.02);
(2)The fused optical fiber is basically not affected by the environment and has low maintenance cost in the later period.
2.What is fiber optic fusion splicer?
Optical fiber splicer is a kind of equipment that fuses two optical fibers together to form a long optical fiber by using high-voltage arc to produce high temperature above 2000℃, so that optical signals can be transferred from one optical fiber to another optical fiber with little loss.
According to different alignment methods, optical fiber fusion splicer can be divided into two categories: cladding alignment and core alignment.
2.1 Cladding alignment
Cladding alignment is the cladding of optical fiber rather than optical fiber. The fiber loss after fusion and splicing is relatively large. It is suitable for short distance transmission, such as optical fiber to the home and other occasions with low requirements, so the price is relatively low.
2.2 Core alignment
The core aligners are equipped with more advanced technology and better performance hardware, which can accurately identify the type of fiber and automatically select the matching welding mode and splice. The welding quality is higher and the loss is lower. It is suitable for all applications of optical fiber welding, so the relative price is higher.
Finally, if you need a core alignment welding machine, then fusion splicer BD-FS-41B is suitable for you, with high welding accuracy, high reliability, military grade, 7 seconds of welding, 18 seconds of heating, cost-effective. If you need a portable machine, I recommend you choose handheld BD-FS-35, 8 second splicing, 30 second heating, easy to use and easy to carry.
3.How to splice fiber optic?
The most efficient way to splice optical fibers is to use an optical fiber splicer. Fusion splicing machine is an automatic machine. You can set your own splicing parameters or use factory-recommended parameters.
Basically, there are nine basic steps to splicing fiber with a splicer.
(1) Firstly, open the fiber Fusion splicer to stand by.
(2) Insert the cooling tree in the back of the heating trough.
(3)Put on the fusion splice protection sleeve.
(4) Peel off the fibers.
Strip off all fiber coating, leaving only 125um of bare fiber, then use 99% isopropyl alcohol to clean the bare fiber.
(5) Cut the fibers.
Open the fiber cleaver pulls the fiber into the fiber cleaver and press the yellow knob in the front to cleave the fiber.
(6)Put the fiber into the fiber holders of the fusion machine.
Press the Start button to start the fusion splicing.
(7) Remove the fiber and reinforce it with a heater.
Take out the optical fiber from the welding machine, put the heat shrink tube into the heater to heat, the heating process is down after hearing the beep, then take out the optical fiber.
(8) Cooling the fiber. Place the heat shrink tube onto the cooling tray to cool down in around 10 to 20 seconds.
(9) Pull out the fiber.
Finally, if you want to know more about this process you can click on the video link below, I hope it helps you.
More information can be found on the website baudcom. fiber MATLAB Answers — New Questions
Creating histograms of a matrix with weights in separate matrix
I have a matrix A with n values, and each value has a corresponding weight in matrix B. How do I create a weighted histogram in this case? I would like to not specify the number of bins, only the binwidth.
Thank you.
Note: There are no repeating values in A, and alos no repeating values in B.
A = randperm(100); % list of values I need a histogram of
B = randperm(100); % weights for every value in A
h = hist(A)
h.BinWidth = 10;I have a matrix A with n values, and each value has a corresponding weight in matrix B. How do I create a weighted histogram in this case? I would like to not specify the number of bins, only the binwidth.
Thank you.
Note: There are no repeating values in A, and alos no repeating values in B.
A = randperm(100); % list of values I need a histogram of
B = randperm(100); % weights for every value in A
h = hist(A)
h.BinWidth = 10; I have a matrix A with n values, and each value has a corresponding weight in matrix B. How do I create a weighted histogram in this case? I would like to not specify the number of bins, only the binwidth.
Thank you.
Note: There are no repeating values in A, and alos no repeating values in B.
A = randperm(100); % list of values I need a histogram of
B = randperm(100); % weights for every value in A
h = hist(A)
h.BinWidth = 10; histogram, weighted histogram MATLAB Answers — New Questions
how to realize look up function in m script
hello, i have x axle table and y axle table, when i set value within the range of x, how to get the output from y, may be some interpolation and curve smoothing should used. i hope it works in m script.hello, i have x axle table and y axle table, when i set value within the range of x, how to get the output from y, may be some interpolation and curve smoothing should used. i hope it works in m script. hello, i have x axle table and y axle table, when i set value within the range of x, how to get the output from y, may be some interpolation and curve smoothing should used. i hope it works in m script. curve fitting, curve smoothing, interpolation MATLAB Answers — New Questions
How to define Block Size Based on Input Image Dimensions in BLOCKPROC with SEMANTICSEG()
Dear all,
I am using the BLOCKPROC command to segment an input image (21828x54644x3) by passing blocks to the SEGMANTICSEG() function. In this case, I found that the smallest block size that executes without error is [2048,2048]. However, when using an even larger input image (22609x24064x3), the command does not execute if I keep the same block size of [2048,2048]. I need to increase the block size slightly, and it worked with a block size of [2100,2100]. I would like to understand the reason for this and how I can determine the smallest block size based on the image size. Could someone help me?
Thank you.
IMG = imread(‘image.tif’);
BlockSize = [2048 2048];
fun_proc_semanticseg = @(bloco)semanticseg(bloco.data, net, ExecutionEnvironment="gpu",
MiniBatchSize=16,OutputType="uint8");
C = blockproc(IMG, BlockSize, fun_proc_semanticseg);Dear all,
I am using the BLOCKPROC command to segment an input image (21828x54644x3) by passing blocks to the SEGMANTICSEG() function. In this case, I found that the smallest block size that executes without error is [2048,2048]. However, when using an even larger input image (22609x24064x3), the command does not execute if I keep the same block size of [2048,2048]. I need to increase the block size slightly, and it worked with a block size of [2100,2100]. I would like to understand the reason for this and how I can determine the smallest block size based on the image size. Could someone help me?
Thank you.
IMG = imread(‘image.tif’);
BlockSize = [2048 2048];
fun_proc_semanticseg = @(bloco)semanticseg(bloco.data, net, ExecutionEnvironment="gpu",
MiniBatchSize=16,OutputType="uint8");
C = blockproc(IMG, BlockSize, fun_proc_semanticseg); Dear all,
I am using the BLOCKPROC command to segment an input image (21828x54644x3) by passing blocks to the SEGMANTICSEG() function. In this case, I found that the smallest block size that executes without error is [2048,2048]. However, when using an even larger input image (22609x24064x3), the command does not execute if I keep the same block size of [2048,2048]. I need to increase the block size slightly, and it worked with a block size of [2100,2100]. I would like to understand the reason for this and how I can determine the smallest block size based on the image size. Could someone help me?
Thank you.
IMG = imread(‘image.tif’);
BlockSize = [2048 2048];
fun_proc_semanticseg = @(bloco)semanticseg(bloco.data, net, ExecutionEnvironment="gpu",
MiniBatchSize=16,OutputType="uint8");
C = blockproc(IMG, BlockSize, fun_proc_semanticseg); blocksize, matlab, blockproc, semanticseg MATLAB Answers — New Questions
Why am I getting gaps in my data when I attempt to interpolate my curve?
I am trying to make finner steps (x) for my data file attached. I am using matlab’s interp function. Upon doing so, I get the curve attached with a big gap in the data. Any idea what I am doing wrong?
xInterp=linspace(Dist(1),Dist(end),2500);%also tried less points (500->1000) and it was worse
yInterp=interp1(Dist,Power,xInterp,’spline’);
figure
plot(xInterp,yInterp)
set(gca, ‘YScale’, ‘log’)I am trying to make finner steps (x) for my data file attached. I am using matlab’s interp function. Upon doing so, I get the curve attached with a big gap in the data. Any idea what I am doing wrong?
xInterp=linspace(Dist(1),Dist(end),2500);%also tried less points (500->1000) and it was worse
yInterp=interp1(Dist,Power,xInterp,’spline’);
figure
plot(xInterp,yInterp)
set(gca, ‘YScale’, ‘log’) I am trying to make finner steps (x) for my data file attached. I am using matlab’s interp function. Upon doing so, I get the curve attached with a big gap in the data. Any idea what I am doing wrong?
xInterp=linspace(Dist(1),Dist(end),2500);%also tried less points (500->1000) and it was worse
yInterp=interp1(Dist,Power,xInterp,’spline’);
figure
plot(xInterp,yInterp)
set(gca, ‘YScale’, ‘log’) interpolation MATLAB Answers — New Questions
How to convert a table containing numbers and booleans to a double array?
using table2array I get a string array, but I need an array of numbers where the booleans become 0 or 1 respectivly. double(table2array(arr)) results in NaN for every boolean valueusing table2array I get a string array, but I need an array of numbers where the booleans become 0 or 1 respectivly. double(table2array(arr)) results in NaN for every boolean value using table2array I get a string array, but I need an array of numbers where the booleans become 0 or 1 respectivly. double(table2array(arr)) results in NaN for every boolean value table, array MATLAB Answers — New Questions
Rate equation for a two level laser
Pumping Stimulated rate
Spontaneous decay ratePumping Stimulated rate
Spontaneous decay rate Pumping Stimulated rate
Spontaneous decay rate two level laser MATLAB Answers — New Questions
Help designing very low pass filters (sub-mHz) for long time series
I am relatively new to filter design so patience is appreciated.
I have an extremely long time series (e.g. ~100 million data points) with a sample rate of 0.2 Hz and I want to apply a series of lowpass filters to the signal at query frequencies of e.g. 1/10 Hz, 1/100 Hz, 1/1000 Hz, 1/10000 Hz, and so on. However, the filtered datasets look roughly identical regardless of what lowpass filter I use.
Fig 1: Zoom view of section of time series to show small differences in filtered time series.
The spectrum of the signal suggests that there is plenty of power at the lower frequencies, so I would think that the results should be different depending on which lowpass cutoff I use.
Fig 2: Spectrum of signal
I wonder if it has something to do with trying to filter sub-mHz levels. Most of the filter questions/answers that I have found are dealing with audio sampling and much higher frequencies. Are there some defaults in MATLAB which design filters to be better behaved at higher frequencies and these assumptions break down at lower frequencies?
I have not done filter design before. All my previous filtering experiences has just used plug-and-play MATLAB functions like lowpass, highpass, bandpass. How would I go about designing an adequate filter for these low frequency signals?
Alternatively, is there nothing wrong with the result and my intuition about what the filter results should look like is just wrong?
Any help is appreciated.I am relatively new to filter design so patience is appreciated.
I have an extremely long time series (e.g. ~100 million data points) with a sample rate of 0.2 Hz and I want to apply a series of lowpass filters to the signal at query frequencies of e.g. 1/10 Hz, 1/100 Hz, 1/1000 Hz, 1/10000 Hz, and so on. However, the filtered datasets look roughly identical regardless of what lowpass filter I use.
Fig 1: Zoom view of section of time series to show small differences in filtered time series.
The spectrum of the signal suggests that there is plenty of power at the lower frequencies, so I would think that the results should be different depending on which lowpass cutoff I use.
Fig 2: Spectrum of signal
I wonder if it has something to do with trying to filter sub-mHz levels. Most of the filter questions/answers that I have found are dealing with audio sampling and much higher frequencies. Are there some defaults in MATLAB which design filters to be better behaved at higher frequencies and these assumptions break down at lower frequencies?
I have not done filter design before. All my previous filtering experiences has just used plug-and-play MATLAB functions like lowpass, highpass, bandpass. How would I go about designing an adequate filter for these low frequency signals?
Alternatively, is there nothing wrong with the result and my intuition about what the filter results should look like is just wrong?
Any help is appreciated. I am relatively new to filter design so patience is appreciated.
I have an extremely long time series (e.g. ~100 million data points) with a sample rate of 0.2 Hz and I want to apply a series of lowpass filters to the signal at query frequencies of e.g. 1/10 Hz, 1/100 Hz, 1/1000 Hz, 1/10000 Hz, and so on. However, the filtered datasets look roughly identical regardless of what lowpass filter I use.
Fig 1: Zoom view of section of time series to show small differences in filtered time series.
The spectrum of the signal suggests that there is plenty of power at the lower frequencies, so I would think that the results should be different depending on which lowpass cutoff I use.
Fig 2: Spectrum of signal
I wonder if it has something to do with trying to filter sub-mHz levels. Most of the filter questions/answers that I have found are dealing with audio sampling and much higher frequencies. Are there some defaults in MATLAB which design filters to be better behaved at higher frequencies and these assumptions break down at lower frequencies?
I have not done filter design before. All my previous filtering experiences has just used plug-and-play MATLAB functions like lowpass, highpass, bandpass. How would I go about designing an adequate filter for these low frequency signals?
Alternatively, is there nothing wrong with the result and my intuition about what the filter results should look like is just wrong?
Any help is appreciated. filter, time series, fft, data, signal processing MATLAB Answers — New Questions
MATLAB recommended me to download the latest pre-released version is there any difference between that and the normal versions
NilNil Nil nil MATLAB Answers — New Questions
Need to extract boundary layer thickness from 2D planar PIV data.
This is 2D Planar PIV data at a freestream velocity of ~ 13 m/s.
My code currently selects a velocity profile where max(profile_u) = 12.41 m/s. I want to use a velocity profile where max(profile_u) is closer to 13 m/s.
Scatter(u,y) will show all the velocity profiles I am working with.
clc;
close all;
clear all;
%% BASELINE
% Load the data
opts = detectImportOptions(‘FlatPlate_Baseline_avg0001(in).csv’);
opts.VariableNamingRule = ‘preserve’;
data = readtable(‘FlatPlate_Baseline_avg0001(in).csv’, opts);
% Extract variables
x = data.x / 1000; % Convert to meters
y = data.y / 1000; % Convert to meters
u = data.u;
v = data.v;
%%
% Filter data for x values between 0.05m to 0.08m
filter_indices = (x >= 0.05) & (x <= 0.08);
x_filtered = x(filter_indices);
y_filtered = y(filter_indices);
u_filtered = u(filter_indices);
v_filtered = v(filter_indices);
% Find unique x and y values within the filtered range
unique_x = unique(x_filtered);
unique_y = unique(y_filtered);
nu = 1.5e-5;
kappa = 0.41;
B = 5.0;
profile_spacing = 2 / 1000;
profile_x_positions = unique_x(unique_x >= 0.05);
wall_shear_stress = zeros(size(profile_x_positions));
u_tau_values = zeros(size(profile_x_positions));
delta_99_values = zeros(size(profile_x_positions));
delta_star_values = zeros(size(profile_x_positions)); % Displacement thickness
theta_values = zeros(size(profile_x_positions)); % Momentum thickness
for i = 1:length(profile_x_positions)
profile_indices = find(abs(x – profile_x_positions(i)) < 1e-6);
profile_y = y(profile_indices);
profile_u = u(profile_indices);
valid_indices = profile_y > 0 & profile_y * max(profile_u) / nu > 1e-6;
profile_y = profile_y(valid_indices);
profile_u = profile_u(valid_indices);
if isempty(profile_y) || isempty(profile_u)
fprintf(‘No valid data points at x = %f meters. Skipping…n’, profile_x_positions(i));
continue;
end
% Estimate u_inf (freestream velocity) as the max value of the profile
u_inf = max(profile_u);
% f(eta) = u / u_inf
f_eta = profile_u / u_inf;
[f_eta_unique, unique_indices] = unique(f_eta);
profile_y_unique = profile_y(unique_indices);
% Find y_99 where f(eta) = 0.99
y_99 = interp1(f_eta_unique, profile_y_unique, 0.99, ‘linear’, ‘extrap’);
eta_99 = 0.99;
% delta_99
delta_99 = y_99 / eta_99;
delta_99_values(i) = delta_99;
% displacement thickness (delta_star)
delta_star = abs(trapz(profile_y, (1 – f_eta)));
delta_star_values(i) = delta_star;
% momentum thickness (theta)
theta = abs(trapz(profile_y, f_eta .* (1 – f_eta)));
theta_values(i) = theta;
Re_theta = (u_inf * theta)/nu;
% Calculate wall shear stress and friction velocity
fun_u_tau = @(u_tau) mean(profile_u – (u_tau / kappa) * log(profile_y * u_tau / nu + 1) – B * u_tau);
try
options = optimset(‘Display’, ‘off’);
u_tau = fzero(fun_u_tau, [0.01, 10], options);
u_tau_values(i) = u_tau;
catch err
fprintf(‘Cannot converge at x = %f meters: %sn’, profile_x_positions(i), err.message);
continue;
end
rho = 1.225;
tau_wall = rho * u_tau^2;
wall_shear_stress(i) = tau_wall;
% % Plot y/delta vs u/u_inf
% figure;
% y_over_delta = profile_y / delta_99;
% u_over_u_inf = profile_u / u_inf;
% plot(u_over_u_inf, y_over_delta, ‘-o’);
% title(sprintf(‘Velocity Profile at x = %.3f meters’, profile_x_positions(i)));
% xlabel(‘u / u_{infty}’);
% ylabel(‘y / delta’);
% grid on;
end
% Display the results
results_table = table(profile_x_positions, delta_99_values, delta_star_values, theta_values);
disp(results_table);
disp([‘Momentum Thickness Reynolds Number (Re_theta): ‘, num2str(Re_theta)]);This is 2D Planar PIV data at a freestream velocity of ~ 13 m/s.
My code currently selects a velocity profile where max(profile_u) = 12.41 m/s. I want to use a velocity profile where max(profile_u) is closer to 13 m/s.
Scatter(u,y) will show all the velocity profiles I am working with.
clc;
close all;
clear all;
%% BASELINE
% Load the data
opts = detectImportOptions(‘FlatPlate_Baseline_avg0001(in).csv’);
opts.VariableNamingRule = ‘preserve’;
data = readtable(‘FlatPlate_Baseline_avg0001(in).csv’, opts);
% Extract variables
x = data.x / 1000; % Convert to meters
y = data.y / 1000; % Convert to meters
u = data.u;
v = data.v;
%%
% Filter data for x values between 0.05m to 0.08m
filter_indices = (x >= 0.05) & (x <= 0.08);
x_filtered = x(filter_indices);
y_filtered = y(filter_indices);
u_filtered = u(filter_indices);
v_filtered = v(filter_indices);
% Find unique x and y values within the filtered range
unique_x = unique(x_filtered);
unique_y = unique(y_filtered);
nu = 1.5e-5;
kappa = 0.41;
B = 5.0;
profile_spacing = 2 / 1000;
profile_x_positions = unique_x(unique_x >= 0.05);
wall_shear_stress = zeros(size(profile_x_positions));
u_tau_values = zeros(size(profile_x_positions));
delta_99_values = zeros(size(profile_x_positions));
delta_star_values = zeros(size(profile_x_positions)); % Displacement thickness
theta_values = zeros(size(profile_x_positions)); % Momentum thickness
for i = 1:length(profile_x_positions)
profile_indices = find(abs(x – profile_x_positions(i)) < 1e-6);
profile_y = y(profile_indices);
profile_u = u(profile_indices);
valid_indices = profile_y > 0 & profile_y * max(profile_u) / nu > 1e-6;
profile_y = profile_y(valid_indices);
profile_u = profile_u(valid_indices);
if isempty(profile_y) || isempty(profile_u)
fprintf(‘No valid data points at x = %f meters. Skipping…n’, profile_x_positions(i));
continue;
end
% Estimate u_inf (freestream velocity) as the max value of the profile
u_inf = max(profile_u);
% f(eta) = u / u_inf
f_eta = profile_u / u_inf;
[f_eta_unique, unique_indices] = unique(f_eta);
profile_y_unique = profile_y(unique_indices);
% Find y_99 where f(eta) = 0.99
y_99 = interp1(f_eta_unique, profile_y_unique, 0.99, ‘linear’, ‘extrap’);
eta_99 = 0.99;
% delta_99
delta_99 = y_99 / eta_99;
delta_99_values(i) = delta_99;
% displacement thickness (delta_star)
delta_star = abs(trapz(profile_y, (1 – f_eta)));
delta_star_values(i) = delta_star;
% momentum thickness (theta)
theta = abs(trapz(profile_y, f_eta .* (1 – f_eta)));
theta_values(i) = theta;
Re_theta = (u_inf * theta)/nu;
% Calculate wall shear stress and friction velocity
fun_u_tau = @(u_tau) mean(profile_u – (u_tau / kappa) * log(profile_y * u_tau / nu + 1) – B * u_tau);
try
options = optimset(‘Display’, ‘off’);
u_tau = fzero(fun_u_tau, [0.01, 10], options);
u_tau_values(i) = u_tau;
catch err
fprintf(‘Cannot converge at x = %f meters: %sn’, profile_x_positions(i), err.message);
continue;
end
rho = 1.225;
tau_wall = rho * u_tau^2;
wall_shear_stress(i) = tau_wall;
% % Plot y/delta vs u/u_inf
% figure;
% y_over_delta = profile_y / delta_99;
% u_over_u_inf = profile_u / u_inf;
% plot(u_over_u_inf, y_over_delta, ‘-o’);
% title(sprintf(‘Velocity Profile at x = %.3f meters’, profile_x_positions(i)));
% xlabel(‘u / u_{infty}’);
% ylabel(‘y / delta’);
% grid on;
end
% Display the results
results_table = table(profile_x_positions, delta_99_values, delta_star_values, theta_values);
disp(results_table);
disp([‘Momentum Thickness Reynolds Number (Re_theta): ‘, num2str(Re_theta)]); This is 2D Planar PIV data at a freestream velocity of ~ 13 m/s.
My code currently selects a velocity profile where max(profile_u) = 12.41 m/s. I want to use a velocity profile where max(profile_u) is closer to 13 m/s.
Scatter(u,y) will show all the velocity profiles I am working with.
clc;
close all;
clear all;
%% BASELINE
% Load the data
opts = detectImportOptions(‘FlatPlate_Baseline_avg0001(in).csv’);
opts.VariableNamingRule = ‘preserve’;
data = readtable(‘FlatPlate_Baseline_avg0001(in).csv’, opts);
% Extract variables
x = data.x / 1000; % Convert to meters
y = data.y / 1000; % Convert to meters
u = data.u;
v = data.v;
%%
% Filter data for x values between 0.05m to 0.08m
filter_indices = (x >= 0.05) & (x <= 0.08);
x_filtered = x(filter_indices);
y_filtered = y(filter_indices);
u_filtered = u(filter_indices);
v_filtered = v(filter_indices);
% Find unique x and y values within the filtered range
unique_x = unique(x_filtered);
unique_y = unique(y_filtered);
nu = 1.5e-5;
kappa = 0.41;
B = 5.0;
profile_spacing = 2 / 1000;
profile_x_positions = unique_x(unique_x >= 0.05);
wall_shear_stress = zeros(size(profile_x_positions));
u_tau_values = zeros(size(profile_x_positions));
delta_99_values = zeros(size(profile_x_positions));
delta_star_values = zeros(size(profile_x_positions)); % Displacement thickness
theta_values = zeros(size(profile_x_positions)); % Momentum thickness
for i = 1:length(profile_x_positions)
profile_indices = find(abs(x – profile_x_positions(i)) < 1e-6);
profile_y = y(profile_indices);
profile_u = u(profile_indices);
valid_indices = profile_y > 0 & profile_y * max(profile_u) / nu > 1e-6;
profile_y = profile_y(valid_indices);
profile_u = profile_u(valid_indices);
if isempty(profile_y) || isempty(profile_u)
fprintf(‘No valid data points at x = %f meters. Skipping…n’, profile_x_positions(i));
continue;
end
% Estimate u_inf (freestream velocity) as the max value of the profile
u_inf = max(profile_u);
% f(eta) = u / u_inf
f_eta = profile_u / u_inf;
[f_eta_unique, unique_indices] = unique(f_eta);
profile_y_unique = profile_y(unique_indices);
% Find y_99 where f(eta) = 0.99
y_99 = interp1(f_eta_unique, profile_y_unique, 0.99, ‘linear’, ‘extrap’);
eta_99 = 0.99;
% delta_99
delta_99 = y_99 / eta_99;
delta_99_values(i) = delta_99;
% displacement thickness (delta_star)
delta_star = abs(trapz(profile_y, (1 – f_eta)));
delta_star_values(i) = delta_star;
% momentum thickness (theta)
theta = abs(trapz(profile_y, f_eta .* (1 – f_eta)));
theta_values(i) = theta;
Re_theta = (u_inf * theta)/nu;
% Calculate wall shear stress and friction velocity
fun_u_tau = @(u_tau) mean(profile_u – (u_tau / kappa) * log(profile_y * u_tau / nu + 1) – B * u_tau);
try
options = optimset(‘Display’, ‘off’);
u_tau = fzero(fun_u_tau, [0.01, 10], options);
u_tau_values(i) = u_tau;
catch err
fprintf(‘Cannot converge at x = %f meters: %sn’, profile_x_positions(i), err.message);
continue;
end
rho = 1.225;
tau_wall = rho * u_tau^2;
wall_shear_stress(i) = tau_wall;
% % Plot y/delta vs u/u_inf
% figure;
% y_over_delta = profile_y / delta_99;
% u_over_u_inf = profile_u / u_inf;
% plot(u_over_u_inf, y_over_delta, ‘-o’);
% title(sprintf(‘Velocity Profile at x = %.3f meters’, profile_x_positions(i)));
% xlabel(‘u / u_{infty}’);
% ylabel(‘y / delta’);
% grid on;
end
% Display the results
results_table = table(profile_x_positions, delta_99_values, delta_star_values, theta_values);
disp(results_table);
disp([‘Momentum Thickness Reynolds Number (Re_theta): ‘, num2str(Re_theta)]); aerodynamics, indexing, plotting, vectors MATLAB Answers — New Questions
How to get optimal number of clusters in data set using fuzzy c means? Please answer this it is very important for my study.
How to get optimal number of clusters in data set using fuzzy c means? Please answer this it is very important for my study.How to get optimal number of clusters in data set using fuzzy c means? Please answer this it is very important for my study. How to get optimal number of clusters in data set using fuzzy c means? Please answer this it is very important for my study. fcm MATLAB Answers — New Questions
Using imrotate without losing quality
I’m in a situation that I need to be able to randomly rotate (0-359 angle degrees) different images. I’m currently using _imrotate()_ but considering that the images are small and the quality is important, I noticed that the images lose their qualities, specially in curve lines. I can still rotate my images 0, 90, 180 and 270 degrees without losing any qualities but I wanted to know if there is any way to rotate an image with more degrees without losing the quality.I’m in a situation that I need to be able to randomly rotate (0-359 angle degrees) different images. I’m currently using _imrotate()_ but considering that the images are small and the quality is important, I noticed that the images lose their qualities, specially in curve lines. I can still rotate my images 0, 90, 180 and 270 degrees without losing any qualities but I wanted to know if there is any way to rotate an image with more degrees without losing the quality. I’m in a situation that I need to be able to randomly rotate (0-359 angle degrees) different images. I’m currently using _imrotate()_ but considering that the images are small and the quality is important, I noticed that the images lose their qualities, specially in curve lines. I can still rotate my images 0, 90, 180 and 270 degrees without losing any qualities but I wanted to know if there is any way to rotate an image with more degrees without losing the quality. image processing, rotate, imrotate, quality, imagequality MATLAB Answers — New Questions
How to use Battery Pulse Analysis with both Discharge and Charge Pulses?
I’m wondering if there is any way to modify analysis described below (see link) so that the code can analyze a mixture of charge and discharge pulses?
I am using the battery discharge pulse analysis described in the link below to analyze the discharge of my batteries. Works great with discharge only pulses!
I have a new data set that includes discharge AND charge pulses, however, and when I try to analyze the data I run into this error "Warning: Battery:InvalidTestType. TestType mixed is not supported."
https://www.mathworks.com/help/autoblks/ug/generate-parameter-data-for-estimations-circuit-battery-block.html
Thank you!I’m wondering if there is any way to modify analysis described below (see link) so that the code can analyze a mixture of charge and discharge pulses?
I am using the battery discharge pulse analysis described in the link below to analyze the discharge of my batteries. Works great with discharge only pulses!
I have a new data set that includes discharge AND charge pulses, however, and when I try to analyze the data I run into this error "Warning: Battery:InvalidTestType. TestType mixed is not supported."
https://www.mathworks.com/help/autoblks/ug/generate-parameter-data-for-estimations-circuit-battery-block.html
Thank you! I’m wondering if there is any way to modify analysis described below (see link) so that the code can analyze a mixture of charge and discharge pulses?
I am using the battery discharge pulse analysis described in the link below to analyze the discharge of my batteries. Works great with discharge only pulses!
I have a new data set that includes discharge AND charge pulses, however, and when I try to analyze the data I run into this error "Warning: Battery:InvalidTestType. TestType mixed is not supported."
https://www.mathworks.com/help/autoblks/ug/generate-parameter-data-for-estimations-circuit-battery-block.html
Thank you! battery, pulse MATLAB Answers — New Questions
How can I resolve this error ?
While simulating model in Simulink I got error as "External input specified in the Configuration Parameters dialog box on the Data Import/Export page (or as an option to SIM command) to a model containing no root level input ports"While simulating model in Simulink I got error as "External input specified in the Configuration Parameters dialog box on the Data Import/Export page (or as an option to SIM command) to a model containing no root level input ports" While simulating model in Simulink I got error as "External input specified in the Configuration Parameters dialog box on the Data Import/Export page (or as an option to SIM command) to a model containing no root level input ports" to workspace, from workspace MATLAB Answers — New Questions
Hello, I would like to know how to draw a shaded region like this?
I am trying to estimate the parameters for a mathematical model, I managed to do it but there remains a problem of determining the confidence interval and drawing the shaded region which contains the majority of the data points.I am trying to estimate the parameters for a mathematical model, I managed to do it but there remains a problem of determining the confidence interval and drawing the shaded region which contains the majority of the data points. I am trying to estimate the parameters for a mathematical model, I managed to do it but there remains a problem of determining the confidence interval and drawing the shaded region which contains the majority of the data points. parameter estimation, confidence interval, curve fitting MATLAB Answers — New Questions
how to plot signals in matlab.ans
how to plot these signals in matlab
y1(t)=x(t-3)
y2(t)=x(t+5)
y3(t)=x(-t)how to plot these signals in matlab
y1(t)=x(t-3)
y2(t)=x(t+5)
y3(t)=x(-t) how to plot these signals in matlab
y1(t)=x(t-3)
y2(t)=x(t+5)
y3(t)=x(-t) signal MATLAB Answers — New Questions
How to pass an object of handle class to the function constructing the app in App Designer?
In my App Designer, the default function that constructs the app takes varargin as input. The function creates UIFigure and Components, registers the app with AppDesigner, and executes the startup function. Say this is represented by "B" (a matlab function with same name as mlapp file created by AppDesigner automatically and cannot be edited because greyed out).
The object of handle class essentially creates the object, creates the structs to store data, and initializes the structs with default/initial data. Say this is represented by "A" (an object of handle class).
I am getting an error when doing:
var_name = B(A);
Error Code:
"Cannot pass an object of handle class ‘A’ to MATLAB function ‘B’"In my App Designer, the default function that constructs the app takes varargin as input. The function creates UIFigure and Components, registers the app with AppDesigner, and executes the startup function. Say this is represented by "B" (a matlab function with same name as mlapp file created by AppDesigner automatically and cannot be edited because greyed out).
The object of handle class essentially creates the object, creates the structs to store data, and initializes the structs with default/initial data. Say this is represented by "A" (an object of handle class).
I am getting an error when doing:
var_name = B(A);
Error Code:
"Cannot pass an object of handle class ‘A’ to MATLAB function ‘B’" In my App Designer, the default function that constructs the app takes varargin as input. The function creates UIFigure and Components, registers the app with AppDesigner, and executes the startup function. Say this is represented by "B" (a matlab function with same name as mlapp file created by AppDesigner automatically and cannot be edited because greyed out).
The object of handle class essentially creates the object, creates the structs to store data, and initializes the structs with default/initial data. Say this is represented by "A" (an object of handle class).
I am getting an error when doing:
var_name = B(A);
Error Code:
"Cannot pass an object of handle class ‘A’ to MATLAB function ‘B’" appdesigner, matlab, matlab gui, simulink, matlab compiler, simulation MATLAB Answers — New Questions