Tag Archives: matlab
how to mirror data and then plot it?
x =0:1:15;
y = tan(x);
plot(x,y)
i hv to mirror data and then plot also .how to do itx =0:1:15;
y = tan(x);
plot(x,y)
i hv to mirror data and then plot also .how to do it x =0:1:15;
y = tan(x);
plot(x,y)
i hv to mirror data and then plot also .how to do it plot MATLAB Answers — New Questions
3D integration over a region bounded by some planes.
I want to perform 3D integrations of some functions over a region defined by the following 16 planes. As an example, consider the function . The region is bounded by:
2 planes parallel to -plane at and .
2 planes parallel to -plane at and .
2 planes parallel to -plane at and .
8 planes which are penpendicular to the vectors – given in below code at mid point of these vector ().
Code to visulize the last 8 planes. First 8 planes are quite eays to imagine.
clear; clc;
figure; hold on;
axis([-1 1 -1 1 -1 1])
% function to calculate the 8 vectors:
f = @(vec) vec(1)*[-1 1 1] + vec(2)*[1 -1 1] + vec(3)*[1 1 -1];
% 8 vectors:
v1 = f([1, 1, 1]);
v2 = f([-1, -1, -1]);
v3 = f([0, 1, 0]);
v4 = f([0, -1, 0]);
v5 = f([0, 0, 1]);
v6 = f([0, 0, -1]);
v7 = f([1, 0, 0]);
v8 = f([-1, 0, 0]);
% draw planes perpendicular to v vectors at v/2 point:
draw_plane(v1)
draw_plane(v2)
draw_plane(v3)
draw_plane(v4)
draw_plane(v5)
draw_plane(v6)
draw_plane(v7)
draw_plane(v8)
xlabel(‘x’);
ylabel(‘y’);
zlabel(‘z’);
box on;
set(gca,’fontname’,’times’,’fontsize’,16)
view([-21 19])
hold off;
function [] = draw_plane(v)
% I took this algorithem from ChatGPT to draw a plane perpendicular to v
plane_size = 3;
midpoint = v./2;
normal_vector = v / norm(v);
perpendicular_vectors = null(normal_vector)’;
[t1, t2] = meshgrid(linspace(-plane_size, plane_size, 100));
plane_points = midpoint + t1(:) * perpendicular_vectors(1,:) + t2(:) * perpendicular_vectors(2,:);
X = reshape(plane_points(:,1), size(t1));
Y = reshape(plane_points(:,2), size(t1));
Z = reshape(plane_points(:,3), size(t1));
surf(X, Y, Z, ‘FaceAlpha’, 0.5, ‘EdgeColor’, ‘none’);
plot3(midpoint(1), midpoint(2), midpoint(3), ‘go’, ‘MarkerSize’, 10, ‘MarkerFaceColor’, ‘g’);
text(midpoint(1), midpoint(2), midpoint(3), [‘(‘,num2str(v(1)),’,’,num2str(v(2)),’,’,num2str(v(3)),’)’]);
endI want to perform 3D integrations of some functions over a region defined by the following 16 planes. As an example, consider the function . The region is bounded by:
2 planes parallel to -plane at and .
2 planes parallel to -plane at and .
2 planes parallel to -plane at and .
8 planes which are penpendicular to the vectors – given in below code at mid point of these vector ().
Code to visulize the last 8 planes. First 8 planes are quite eays to imagine.
clear; clc;
figure; hold on;
axis([-1 1 -1 1 -1 1])
% function to calculate the 8 vectors:
f = @(vec) vec(1)*[-1 1 1] + vec(2)*[1 -1 1] + vec(3)*[1 1 -1];
% 8 vectors:
v1 = f([1, 1, 1]);
v2 = f([-1, -1, -1]);
v3 = f([0, 1, 0]);
v4 = f([0, -1, 0]);
v5 = f([0, 0, 1]);
v6 = f([0, 0, -1]);
v7 = f([1, 0, 0]);
v8 = f([-1, 0, 0]);
% draw planes perpendicular to v vectors at v/2 point:
draw_plane(v1)
draw_plane(v2)
draw_plane(v3)
draw_plane(v4)
draw_plane(v5)
draw_plane(v6)
draw_plane(v7)
draw_plane(v8)
xlabel(‘x’);
ylabel(‘y’);
zlabel(‘z’);
box on;
set(gca,’fontname’,’times’,’fontsize’,16)
view([-21 19])
hold off;
function [] = draw_plane(v)
% I took this algorithem from ChatGPT to draw a plane perpendicular to v
plane_size = 3;
midpoint = v./2;
normal_vector = v / norm(v);
perpendicular_vectors = null(normal_vector)’;
[t1, t2] = meshgrid(linspace(-plane_size, plane_size, 100));
plane_points = midpoint + t1(:) * perpendicular_vectors(1,:) + t2(:) * perpendicular_vectors(2,:);
X = reshape(plane_points(:,1), size(t1));
Y = reshape(plane_points(:,2), size(t1));
Z = reshape(plane_points(:,3), size(t1));
surf(X, Y, Z, ‘FaceAlpha’, 0.5, ‘EdgeColor’, ‘none’);
plot3(midpoint(1), midpoint(2), midpoint(3), ‘go’, ‘MarkerSize’, 10, ‘MarkerFaceColor’, ‘g’);
text(midpoint(1), midpoint(2), midpoint(3), [‘(‘,num2str(v(1)),’,’,num2str(v(2)),’,’,num2str(v(3)),’)’]);
end I want to perform 3D integrations of some functions over a region defined by the following 16 planes. As an example, consider the function . The region is bounded by:
2 planes parallel to -plane at and .
2 planes parallel to -plane at and .
2 planes parallel to -plane at and .
8 planes which are penpendicular to the vectors – given in below code at mid point of these vector ().
Code to visulize the last 8 planes. First 8 planes are quite eays to imagine.
clear; clc;
figure; hold on;
axis([-1 1 -1 1 -1 1])
% function to calculate the 8 vectors:
f = @(vec) vec(1)*[-1 1 1] + vec(2)*[1 -1 1] + vec(3)*[1 1 -1];
% 8 vectors:
v1 = f([1, 1, 1]);
v2 = f([-1, -1, -1]);
v3 = f([0, 1, 0]);
v4 = f([0, -1, 0]);
v5 = f([0, 0, 1]);
v6 = f([0, 0, -1]);
v7 = f([1, 0, 0]);
v8 = f([-1, 0, 0]);
% draw planes perpendicular to v vectors at v/2 point:
draw_plane(v1)
draw_plane(v2)
draw_plane(v3)
draw_plane(v4)
draw_plane(v5)
draw_plane(v6)
draw_plane(v7)
draw_plane(v8)
xlabel(‘x’);
ylabel(‘y’);
zlabel(‘z’);
box on;
set(gca,’fontname’,’times’,’fontsize’,16)
view([-21 19])
hold off;
function [] = draw_plane(v)
% I took this algorithem from ChatGPT to draw a plane perpendicular to v
plane_size = 3;
midpoint = v./2;
normal_vector = v / norm(v);
perpendicular_vectors = null(normal_vector)’;
[t1, t2] = meshgrid(linspace(-plane_size, plane_size, 100));
plane_points = midpoint + t1(:) * perpendicular_vectors(1,:) + t2(:) * perpendicular_vectors(2,:);
X = reshape(plane_points(:,1), size(t1));
Y = reshape(plane_points(:,2), size(t1));
Z = reshape(plane_points(:,3), size(t1));
surf(X, Y, Z, ‘FaceAlpha’, 0.5, ‘EdgeColor’, ‘none’);
plot3(midpoint(1), midpoint(2), midpoint(3), ‘go’, ‘MarkerSize’, 10, ‘MarkerFaceColor’, ‘g’);
text(midpoint(1), midpoint(2), midpoint(3), [‘(‘,num2str(v(1)),’,’,num2str(v(2)),’,’,num2str(v(3)),’)’]);
end integral, integration, numerical integration MATLAB Answers — New Questions
ETET EETEWWT EWTEWT EWTEWEWT EWTEW TETEW TET ETETEWTETEWTEWT
TESSETTESSET TESSET test MATLAB Answers — New Questions
Buzzling sound when playing 16-ch audio to Motu Pro Audio
I have problem when play my sound to Motu. There is "nuzzling sound" during the silence part of your audio, especially in the end of audio.
original audio
after_played_to_16ch
Am I correctly use this code to play in using Motu?
I don’t have any issue when I play directly from Audacity or Reaper.
Thanks
% Define the file and volume settings
audioFile = ‘chapel2m_0_order3_02_eight_new_shoes.wav’; % Path to your audio file
volumeLevel = 0.01; % Desired volume level (0 to 1)
% Get audio file information
info = audioinfo(audioFile);
fs = info.TotalSamples / info.Duration; % Sample rate of the audio file
numChannels = info.NumChannels; % Number of channels in the audio file
% Create an audio file reader
fileReader = dsp.AudioFileReader(audioFile, ‘PlayCount’, Inf);
fileReader.SamplesPerFrame = 8192; % Larger buffer size to avoid underflow/overflow
% Create an audio device writer with ASIO driver and MOTU Pro Audio device
deviceWriter = audioDeviceWriter(‘Driver’, ‘ASIO’, ‘Device’, ‘MOTU Pro Audio’, …
‘SampleRate’, fs, ‘ChannelMappingSource’, ‘Auto’);
% Setup the audio device writer with the correct sample rate and channel mapping
setup(deviceWriter, zeros(fileReader.SamplesPerFrame, numChannels));
% Process and play the audio
while ~isDone(fileReader)
% Read audio data
audioData = fileReader();
% Adjust the audio data by the volume level
audioData = audioData * volumeLevel;
% Write the adjusted audio data to the device
deviceWriter(audioData);
end
% Release resources
release(fileReader);
release(deviceWriter);I have problem when play my sound to Motu. There is "nuzzling sound" during the silence part of your audio, especially in the end of audio.
original audio
after_played_to_16ch
Am I correctly use this code to play in using Motu?
I don’t have any issue when I play directly from Audacity or Reaper.
Thanks
% Define the file and volume settings
audioFile = ‘chapel2m_0_order3_02_eight_new_shoes.wav’; % Path to your audio file
volumeLevel = 0.01; % Desired volume level (0 to 1)
% Get audio file information
info = audioinfo(audioFile);
fs = info.TotalSamples / info.Duration; % Sample rate of the audio file
numChannels = info.NumChannels; % Number of channels in the audio file
% Create an audio file reader
fileReader = dsp.AudioFileReader(audioFile, ‘PlayCount’, Inf);
fileReader.SamplesPerFrame = 8192; % Larger buffer size to avoid underflow/overflow
% Create an audio device writer with ASIO driver and MOTU Pro Audio device
deviceWriter = audioDeviceWriter(‘Driver’, ‘ASIO’, ‘Device’, ‘MOTU Pro Audio’, …
‘SampleRate’, fs, ‘ChannelMappingSource’, ‘Auto’);
% Setup the audio device writer with the correct sample rate and channel mapping
setup(deviceWriter, zeros(fileReader.SamplesPerFrame, numChannels));
% Process and play the audio
while ~isDone(fileReader)
% Read audio data
audioData = fileReader();
% Adjust the audio data by the volume level
audioData = audioData * volumeLevel;
% Write the adjusted audio data to the device
deviceWriter(audioData);
end
% Release resources
release(fileReader);
release(deviceWriter); I have problem when play my sound to Motu. There is "nuzzling sound" during the silence part of your audio, especially in the end of audio.
original audio
after_played_to_16ch
Am I correctly use this code to play in using Motu?
I don’t have any issue when I play directly from Audacity or Reaper.
Thanks
% Define the file and volume settings
audioFile = ‘chapel2m_0_order3_02_eight_new_shoes.wav’; % Path to your audio file
volumeLevel = 0.01; % Desired volume level (0 to 1)
% Get audio file information
info = audioinfo(audioFile);
fs = info.TotalSamples / info.Duration; % Sample rate of the audio file
numChannels = info.NumChannels; % Number of channels in the audio file
% Create an audio file reader
fileReader = dsp.AudioFileReader(audioFile, ‘PlayCount’, Inf);
fileReader.SamplesPerFrame = 8192; % Larger buffer size to avoid underflow/overflow
% Create an audio device writer with ASIO driver and MOTU Pro Audio device
deviceWriter = audioDeviceWriter(‘Driver’, ‘ASIO’, ‘Device’, ‘MOTU Pro Audio’, …
‘SampleRate’, fs, ‘ChannelMappingSource’, ‘Auto’);
% Setup the audio device writer with the correct sample rate and channel mapping
setup(deviceWriter, zeros(fileReader.SamplesPerFrame, numChannels));
% Process and play the audio
while ~isDone(fileReader)
% Read audio data
audioData = fileReader();
% Adjust the audio data by the volume level
audioData = audioData * volumeLevel;
% Write the adjusted audio data to the device
deviceWriter(audioData);
end
% Release resources
release(fileReader);
release(deviceWriter); audio, motu, 16-channel MATLAB Answers — New Questions
tleread() loading incorrect data
Hello,
I’m trying to load TLE data to MATLAB using tleread function. Examining the MeanMotion values, they seem to either be loaded incorrectly or some conversion is going on. I tried to look in the help files for the tleread but couldn’t find any details.
For instance, this is the tle data for the Iridium constellation: https://celestrak.org/NORAD/elements/gp.php?GROUP=iridium&FORMAT=tle
When saved as a .tle file and loaded to MATLAB, the MeanMotion values are incorrect.
I’m using MATLAB online, so version R2024a. I also tried it on a locally installed MATLAB (2024a), and getting the same results.
Am I missing something?Hello,
I’m trying to load TLE data to MATLAB using tleread function. Examining the MeanMotion values, they seem to either be loaded incorrectly or some conversion is going on. I tried to look in the help files for the tleread but couldn’t find any details.
For instance, this is the tle data for the Iridium constellation: https://celestrak.org/NORAD/elements/gp.php?GROUP=iridium&FORMAT=tle
When saved as a .tle file and loaded to MATLAB, the MeanMotion values are incorrect.
I’m using MATLAB online, so version R2024a. I also tried it on a locally installed MATLAB (2024a), and getting the same results.
Am I missing something? Hello,
I’m trying to load TLE data to MATLAB using tleread function. Examining the MeanMotion values, they seem to either be loaded incorrectly or some conversion is going on. I tried to look in the help files for the tleread but couldn’t find any details.
For instance, this is the tle data for the Iridium constellation: https://celestrak.org/NORAD/elements/gp.php?GROUP=iridium&FORMAT=tle
When saved as a .tle file and loaded to MATLAB, the MeanMotion values are incorrect.
I’m using MATLAB online, so version R2024a. I also tried it on a locally installed MATLAB (2024a), and getting the same results.
Am I missing something? satellite, tle data, constellation MATLAB Answers — New Questions
timeout error when output of entry-point function is vector with PIL configuration
Greetings
I’m working on deploying deep learning on raspberry pi 4 with matlab version 2024a. I’m facing timeout error when output of entry-point function with PIL configuration is vector. however when configuration is mex, the code has successfully implemtned. Simple code below can demonstrate the issue.
Kindly, how the code with PIL configuration can be fixed so that the output from entry-point function is vector or matrix ?
the driver for this request is described in more details in my case study below.
% raspberry connection and configuration
r = raspi(‘raspberrypi’,’pi’,’raspberry’);
cfg = coder.config(‘lib’,’ecoder’,true);
cfg.VerificationMode = ‘PIL’;
cfg.TargetLang = ‘C++’;
dlcfg = coder.DeepLearningConfig(‘arm-compute’);
dlcfg.ArmComputeVersion = ‘20.02.1’;
dlcfg.ArmArchitecture = ‘armv7’;
cfg.DeepLearningConfig = dlcfg;
cfg.MATLABSourceComments = 1;
hw = coder.hardware(‘Raspberry Pi’);
cfg.Hardware = hw;
cfg.CodeExecutionProfiling = true;
Case 1: with mex configuration, successfuly implemented
type dummy
t = ones(1,3);
codegen dummy -args {t} -report -config:mex
% testing deployement
x=[1,2,3];
testDummy= dummy_mex(x);
Case 2: with pil configuraiton, timeout error generated
type dummy
cfg.Hardware.BuildDir = ‘~/dummy’;
t = ones(1,3);
codegen dummy -args {t} -report -config cfg
% testing deployement
x=[1,2,3];
testDummy= dummy_pil(x);
entry-point function
function out = dummy(in)
%#codegen
out = in;
end
Case Study
my case study has raw data consists of 8 channels where I need to extract features from wavelet scattering network then pass them into trained lstm network. My code is similar to the below example, but the difference is my input raw data is 8 channels, while the example is one channel. openExample(‘wavelet/CodeGenerationForFaultDetectionUsingWaveletAndRNNExample’).
I’m getting the below error:
Number of features of input passed to the predict method must be a code generation time constant
So, I decided to breakdown entry-point function into two functions for easier troubleshooting. First featureFunction is to extract wavelet features from raw data (batch: 500samples x 8 channels), the second predictFunction is to take the generated wavelet features (32 C x 102 T) into trained lstm network.
prdictFunction_pil worked find which accept input size (32 x 102), and get predicted labels.
featureFunction_pil gives the below error
Error using rtw.pil.SILPILInterface.throwMException (line 1774)
The timeout of 300 seconds for receiving data from the rtiostream interface has been exceeded. There might be multiple reasons for this communications failure.
You should:
(a) Check that the target hardware configuration is correct, for example, check that the byte ordering is correct.
(b) Confirm that the target application is running on the target hardware.
(c) Consider the possibility of application run-time failures (e.g. divide by zero exceptions, incorrect custom code integration, etc.).
Note (c): To identify possible reasons for the run-time failure, consider using SIL, which supports signal handlers and debugging.
If you cannot find a solution, consider using the method setTimeoutRecvSecs of rtw.connectivity.RtIOStreamHostCommunicator to increase the timeout value.Greetings
I’m working on deploying deep learning on raspberry pi 4 with matlab version 2024a. I’m facing timeout error when output of entry-point function with PIL configuration is vector. however when configuration is mex, the code has successfully implemtned. Simple code below can demonstrate the issue.
Kindly, how the code with PIL configuration can be fixed so that the output from entry-point function is vector or matrix ?
the driver for this request is described in more details in my case study below.
% raspberry connection and configuration
r = raspi(‘raspberrypi’,’pi’,’raspberry’);
cfg = coder.config(‘lib’,’ecoder’,true);
cfg.VerificationMode = ‘PIL’;
cfg.TargetLang = ‘C++’;
dlcfg = coder.DeepLearningConfig(‘arm-compute’);
dlcfg.ArmComputeVersion = ‘20.02.1’;
dlcfg.ArmArchitecture = ‘armv7’;
cfg.DeepLearningConfig = dlcfg;
cfg.MATLABSourceComments = 1;
hw = coder.hardware(‘Raspberry Pi’);
cfg.Hardware = hw;
cfg.CodeExecutionProfiling = true;
Case 1: with mex configuration, successfuly implemented
type dummy
t = ones(1,3);
codegen dummy -args {t} -report -config:mex
% testing deployement
x=[1,2,3];
testDummy= dummy_mex(x);
Case 2: with pil configuraiton, timeout error generated
type dummy
cfg.Hardware.BuildDir = ‘~/dummy’;
t = ones(1,3);
codegen dummy -args {t} -report -config cfg
% testing deployement
x=[1,2,3];
testDummy= dummy_pil(x);
entry-point function
function out = dummy(in)
%#codegen
out = in;
end
Case Study
my case study has raw data consists of 8 channels where I need to extract features from wavelet scattering network then pass them into trained lstm network. My code is similar to the below example, but the difference is my input raw data is 8 channels, while the example is one channel. openExample(‘wavelet/CodeGenerationForFaultDetectionUsingWaveletAndRNNExample’).
I’m getting the below error:
Number of features of input passed to the predict method must be a code generation time constant
So, I decided to breakdown entry-point function into two functions for easier troubleshooting. First featureFunction is to extract wavelet features from raw data (batch: 500samples x 8 channels), the second predictFunction is to take the generated wavelet features (32 C x 102 T) into trained lstm network.
prdictFunction_pil worked find which accept input size (32 x 102), and get predicted labels.
featureFunction_pil gives the below error
Error using rtw.pil.SILPILInterface.throwMException (line 1774)
The timeout of 300 seconds for receiving data from the rtiostream interface has been exceeded. There might be multiple reasons for this communications failure.
You should:
(a) Check that the target hardware configuration is correct, for example, check that the byte ordering is correct.
(b) Confirm that the target application is running on the target hardware.
(c) Consider the possibility of application run-time failures (e.g. divide by zero exceptions, incorrect custom code integration, etc.).
Note (c): To identify possible reasons for the run-time failure, consider using SIL, which supports signal handlers and debugging.
If you cannot find a solution, consider using the method setTimeoutRecvSecs of rtw.connectivity.RtIOStreamHostCommunicator to increase the timeout value. Greetings
I’m working on deploying deep learning on raspberry pi 4 with matlab version 2024a. I’m facing timeout error when output of entry-point function with PIL configuration is vector. however when configuration is mex, the code has successfully implemtned. Simple code below can demonstrate the issue.
Kindly, how the code with PIL configuration can be fixed so that the output from entry-point function is vector or matrix ?
the driver for this request is described in more details in my case study below.
% raspberry connection and configuration
r = raspi(‘raspberrypi’,’pi’,’raspberry’);
cfg = coder.config(‘lib’,’ecoder’,true);
cfg.VerificationMode = ‘PIL’;
cfg.TargetLang = ‘C++’;
dlcfg = coder.DeepLearningConfig(‘arm-compute’);
dlcfg.ArmComputeVersion = ‘20.02.1’;
dlcfg.ArmArchitecture = ‘armv7’;
cfg.DeepLearningConfig = dlcfg;
cfg.MATLABSourceComments = 1;
hw = coder.hardware(‘Raspberry Pi’);
cfg.Hardware = hw;
cfg.CodeExecutionProfiling = true;
Case 1: with mex configuration, successfuly implemented
type dummy
t = ones(1,3);
codegen dummy -args {t} -report -config:mex
% testing deployement
x=[1,2,3];
testDummy= dummy_mex(x);
Case 2: with pil configuraiton, timeout error generated
type dummy
cfg.Hardware.BuildDir = ‘~/dummy’;
t = ones(1,3);
codegen dummy -args {t} -report -config cfg
% testing deployement
x=[1,2,3];
testDummy= dummy_pil(x);
entry-point function
function out = dummy(in)
%#codegen
out = in;
end
Case Study
my case study has raw data consists of 8 channels where I need to extract features from wavelet scattering network then pass them into trained lstm network. My code is similar to the below example, but the difference is my input raw data is 8 channels, while the example is one channel. openExample(‘wavelet/CodeGenerationForFaultDetectionUsingWaveletAndRNNExample’).
I’m getting the below error:
Number of features of input passed to the predict method must be a code generation time constant
So, I decided to breakdown entry-point function into two functions for easier troubleshooting. First featureFunction is to extract wavelet features from raw data (batch: 500samples x 8 channels), the second predictFunction is to take the generated wavelet features (32 C x 102 T) into trained lstm network.
prdictFunction_pil worked find which accept input size (32 x 102), and get predicted labels.
featureFunction_pil gives the below error
Error using rtw.pil.SILPILInterface.throwMException (line 1774)
The timeout of 300 seconds for receiving data from the rtiostream interface has been exceeded. There might be multiple reasons for this communications failure.
You should:
(a) Check that the target hardware configuration is correct, for example, check that the byte ordering is correct.
(b) Confirm that the target application is running on the target hardware.
(c) Consider the possibility of application run-time failures (e.g. divide by zero exceptions, incorrect custom code integration, etc.).
Note (c): To identify possible reasons for the run-time failure, consider using SIL, which supports signal handlers and debugging.
If you cannot find a solution, consider using the method setTimeoutRecvSecs of rtw.connectivity.RtIOStreamHostCommunicator to increase the timeout value. code generation, matlab coder, raspberry, deployment MATLAB Answers — New Questions
How do I find the width of a curve at 1/e^2 but there are multiple points at this value
I am trying to find the width of a curve taken from the intensity vs x-index of an image (see below) at intensity = 1/e^2, essentially finding the beam diameter of a laser.
The resulting plot is:
The value of 1/e^2 is -3.55e4. Right now its calculating the width from the red points on the plot, but I’d like it to calculate the points from the green points. I’ve tried making it so it finds the points where the slope is negative, but that doesn’t seem to work. Even if you have an idea of how to do this that would be helpful, I can try to figure out the code from there. Still pretty new to matlab.
My code is:
clear
im=imread("D:THORS Imaging8.06.24Result of on_20000-off_20000.tif")
im=imrotate(im, -96,"bilinear")
im=imcrop(im, [200, 450, 700, 150]);
result=im
imshow(result)
%Sums pixel intensity in each verticle column
vertsum = sum(result, 1);
%Subtracts maximum intensity
vertsum =vertsum-max(vertsum);
%Sets threshold for baseline intensity
thresholdhigh = -100; %Threshold value chosen base on intensity of image
%Remove points above the threshold
vertsum = vertsum(vertsum <= thresholdhigh);
%Performs moving average on data
vertsum = movmean(vertsum,100);
%Sets data points fo create the Gaussian fit
[xData, yData] = prepareCurveData( [], vertsum );
%Sets conversion factor between pixels and cm
conversion = 3.5/1024;
%Convert pixels to cm
xcm = xData * conversion;
%Generates plot
plot(xcm, yData );
%% Find width of barrier
%Set the height of the fitted curve equal to the distance between 0 and the
%Height of intensity value
min = min(yData)
max=max(yData)
height=max-min
%Sets variable for 1/e^2, chosen due to gaussian shape of the beam
e = (1/((2.718281828459045)^2))
%Sets y-value on the curve at 1/e^2
pointY = max-(height * e)
%Finds nearest left side x-value on curve at 1/e^2
leftIndexWidth = find(yData <= pointY, 1, ‘first’)
%Finds nearest right side y-value on curve at 1/e^2
rightIndexWidth = find(yData <= pointY, 1, ‘last’)
%Converts pixel coordinate to cm
leftIndexWidth = leftIndexWidth * conversion
rightIndexWidth = rightIndexWidth * conversion
%Calculates width of curve at 1/e^2
widthpx = rightIndexWidth – leftIndexWidthI am trying to find the width of a curve taken from the intensity vs x-index of an image (see below) at intensity = 1/e^2, essentially finding the beam diameter of a laser.
The resulting plot is:
The value of 1/e^2 is -3.55e4. Right now its calculating the width from the red points on the plot, but I’d like it to calculate the points from the green points. I’ve tried making it so it finds the points where the slope is negative, but that doesn’t seem to work. Even if you have an idea of how to do this that would be helpful, I can try to figure out the code from there. Still pretty new to matlab.
My code is:
clear
im=imread("D:THORS Imaging8.06.24Result of on_20000-off_20000.tif")
im=imrotate(im, -96,"bilinear")
im=imcrop(im, [200, 450, 700, 150]);
result=im
imshow(result)
%Sums pixel intensity in each verticle column
vertsum = sum(result, 1);
%Subtracts maximum intensity
vertsum =vertsum-max(vertsum);
%Sets threshold for baseline intensity
thresholdhigh = -100; %Threshold value chosen base on intensity of image
%Remove points above the threshold
vertsum = vertsum(vertsum <= thresholdhigh);
%Performs moving average on data
vertsum = movmean(vertsum,100);
%Sets data points fo create the Gaussian fit
[xData, yData] = prepareCurveData( [], vertsum );
%Sets conversion factor between pixels and cm
conversion = 3.5/1024;
%Convert pixels to cm
xcm = xData * conversion;
%Generates plot
plot(xcm, yData );
%% Find width of barrier
%Set the height of the fitted curve equal to the distance between 0 and the
%Height of intensity value
min = min(yData)
max=max(yData)
height=max-min
%Sets variable for 1/e^2, chosen due to gaussian shape of the beam
e = (1/((2.718281828459045)^2))
%Sets y-value on the curve at 1/e^2
pointY = max-(height * e)
%Finds nearest left side x-value on curve at 1/e^2
leftIndexWidth = find(yData <= pointY, 1, ‘first’)
%Finds nearest right side y-value on curve at 1/e^2
rightIndexWidth = find(yData <= pointY, 1, ‘last’)
%Converts pixel coordinate to cm
leftIndexWidth = leftIndexWidth * conversion
rightIndexWidth = rightIndexWidth * conversion
%Calculates width of curve at 1/e^2
widthpx = rightIndexWidth – leftIndexWidth I am trying to find the width of a curve taken from the intensity vs x-index of an image (see below) at intensity = 1/e^2, essentially finding the beam diameter of a laser.
The resulting plot is:
The value of 1/e^2 is -3.55e4. Right now its calculating the width from the red points on the plot, but I’d like it to calculate the points from the green points. I’ve tried making it so it finds the points where the slope is negative, but that doesn’t seem to work. Even if you have an idea of how to do this that would be helpful, I can try to figure out the code from there. Still pretty new to matlab.
My code is:
clear
im=imread("D:THORS Imaging8.06.24Result of on_20000-off_20000.tif")
im=imrotate(im, -96,"bilinear")
im=imcrop(im, [200, 450, 700, 150]);
result=im
imshow(result)
%Sums pixel intensity in each verticle column
vertsum = sum(result, 1);
%Subtracts maximum intensity
vertsum =vertsum-max(vertsum);
%Sets threshold for baseline intensity
thresholdhigh = -100; %Threshold value chosen base on intensity of image
%Remove points above the threshold
vertsum = vertsum(vertsum <= thresholdhigh);
%Performs moving average on data
vertsum = movmean(vertsum,100);
%Sets data points fo create the Gaussian fit
[xData, yData] = prepareCurveData( [], vertsum );
%Sets conversion factor between pixels and cm
conversion = 3.5/1024;
%Convert pixels to cm
xcm = xData * conversion;
%Generates plot
plot(xcm, yData );
%% Find width of barrier
%Set the height of the fitted curve equal to the distance between 0 and the
%Height of intensity value
min = min(yData)
max=max(yData)
height=max-min
%Sets variable for 1/e^2, chosen due to gaussian shape of the beam
e = (1/((2.718281828459045)^2))
%Sets y-value on the curve at 1/e^2
pointY = max-(height * e)
%Finds nearest left side x-value on curve at 1/e^2
leftIndexWidth = find(yData <= pointY, 1, ‘first’)
%Finds nearest right side y-value on curve at 1/e^2
rightIndexWidth = find(yData <= pointY, 1, ‘last’)
%Converts pixel coordinate to cm
leftIndexWidth = leftIndexWidth * conversion
rightIndexWidth = rightIndexWidth * conversion
%Calculates width of curve at 1/e^2
widthpx = rightIndexWidth – leftIndexWidth fwhm, curve fitting MATLAB Answers — New Questions
How do I solve system of differentials using ode45 and eom functions
Hello and thank you for taking the time to read my question!
I am trying to solve a system of differential equations for analytically and then numerically for and and plot the two for comparison. I also have to analytically find tension T in terms of theta then numerically find it in terms of time. The given equations for motion in normal-tangiential form are , and . The starting position is at rad with m=2 kg, g=9.81 m/s^2, and r=0.5 m.
Below is my code so far. I keep getting an error trying to run the ode45 function saying that inputs must be floats, namely a single or double. I have to use the ode45 function as a requirment for the assignment, but I’m not sure if I have to use the eom bit.
Error:
Error using superiorfloat (line 13)
Inputs must be floats,
namely single or double.
Error in odearguments (line 114)
dataType = superiorfloat(t0,y0,f0);
Error in ode45 (line 104)
odearguments(odeIsFuncHandle,odeTreatAsMFile, solver_name, ode, tspan, y0, options, varargin);
Error in ESCI204_M1_Myers (line 74)
[T,S] = ode45(@eom,linspace(0,2,101),[0,0]);
Code:
%Givens:
theta0 = -pi/6;
m = 2;
g = 9.81;
r = 0.5;
syms Tens theta t thetaA
thetaA = linspace(-pi/6,pi/6,101);
% % DETERMINE ANALYTICALLY:————————————————
%Equation for angular velocity in terms of theta
thetadA = sqrt((-360*g/(pi*r))*(cos(theta0)-cos(thetaA)));
%Equation for Tension in terms of theta
TensA = 3*m*g*cos(thetaA)-2*m*g;
hold on
plot(thetaA,thetadA, ‘black’) %analytical solution for thetad(theta)
xlabel(‘Angular Position (rad) or time (t)’)
ylabel(‘Angular Velocity (rad/sec)’)
% % DETERMINE NUMERICALLY:
% 1) The angular velocity and angular position of the mass about point C
% as a function of time by integration of the equation of motion, thetadd
% 2) The tension in the string as a function of time.
function ds = eom(t,s) %S is current states – vector of current position and vel
%Givens:
theta0 = -pi/6;
m = 2;
g = 9.81;
r = 0.5;
syms Tens
ds(1,1) = sqrt((Tens-m*g*cos(s(1)))/(m*r)); % Derivative of position (s(1) = thetad
ds(2,1) = (-g*sin(s(1)))/r; % Derivative of velocity = thetadd
end
[T,S] = ode45(@eom,linspace(0,2,101),[0,0]);Hello and thank you for taking the time to read my question!
I am trying to solve a system of differential equations for analytically and then numerically for and and plot the two for comparison. I also have to analytically find tension T in terms of theta then numerically find it in terms of time. The given equations for motion in normal-tangiential form are , and . The starting position is at rad with m=2 kg, g=9.81 m/s^2, and r=0.5 m.
Below is my code so far. I keep getting an error trying to run the ode45 function saying that inputs must be floats, namely a single or double. I have to use the ode45 function as a requirment for the assignment, but I’m not sure if I have to use the eom bit.
Error:
Error using superiorfloat (line 13)
Inputs must be floats,
namely single or double.
Error in odearguments (line 114)
dataType = superiorfloat(t0,y0,f0);
Error in ode45 (line 104)
odearguments(odeIsFuncHandle,odeTreatAsMFile, solver_name, ode, tspan, y0, options, varargin);
Error in ESCI204_M1_Myers (line 74)
[T,S] = ode45(@eom,linspace(0,2,101),[0,0]);
Code:
%Givens:
theta0 = -pi/6;
m = 2;
g = 9.81;
r = 0.5;
syms Tens theta t thetaA
thetaA = linspace(-pi/6,pi/6,101);
% % DETERMINE ANALYTICALLY:————————————————
%Equation for angular velocity in terms of theta
thetadA = sqrt((-360*g/(pi*r))*(cos(theta0)-cos(thetaA)));
%Equation for Tension in terms of theta
TensA = 3*m*g*cos(thetaA)-2*m*g;
hold on
plot(thetaA,thetadA, ‘black’) %analytical solution for thetad(theta)
xlabel(‘Angular Position (rad) or time (t)’)
ylabel(‘Angular Velocity (rad/sec)’)
% % DETERMINE NUMERICALLY:
% 1) The angular velocity and angular position of the mass about point C
% as a function of time by integration of the equation of motion, thetadd
% 2) The tension in the string as a function of time.
function ds = eom(t,s) %S is current states – vector of current position and vel
%Givens:
theta0 = -pi/6;
m = 2;
g = 9.81;
r = 0.5;
syms Tens
ds(1,1) = sqrt((Tens-m*g*cos(s(1)))/(m*r)); % Derivative of position (s(1) = thetad
ds(2,1) = (-g*sin(s(1)))/r; % Derivative of velocity = thetadd
end
[T,S] = ode45(@eom,linspace(0,2,101),[0,0]); Hello and thank you for taking the time to read my question!
I am trying to solve a system of differential equations for analytically and then numerically for and and plot the two for comparison. I also have to analytically find tension T in terms of theta then numerically find it in terms of time. The given equations for motion in normal-tangiential form are , and . The starting position is at rad with m=2 kg, g=9.81 m/s^2, and r=0.5 m.
Below is my code so far. I keep getting an error trying to run the ode45 function saying that inputs must be floats, namely a single or double. I have to use the ode45 function as a requirment for the assignment, but I’m not sure if I have to use the eom bit.
Error:
Error using superiorfloat (line 13)
Inputs must be floats,
namely single or double.
Error in odearguments (line 114)
dataType = superiorfloat(t0,y0,f0);
Error in ode45 (line 104)
odearguments(odeIsFuncHandle,odeTreatAsMFile, solver_name, ode, tspan, y0, options, varargin);
Error in ESCI204_M1_Myers (line 74)
[T,S] = ode45(@eom,linspace(0,2,101),[0,0]);
Code:
%Givens:
theta0 = -pi/6;
m = 2;
g = 9.81;
r = 0.5;
syms Tens theta t thetaA
thetaA = linspace(-pi/6,pi/6,101);
% % DETERMINE ANALYTICALLY:————————————————
%Equation for angular velocity in terms of theta
thetadA = sqrt((-360*g/(pi*r))*(cos(theta0)-cos(thetaA)));
%Equation for Tension in terms of theta
TensA = 3*m*g*cos(thetaA)-2*m*g;
hold on
plot(thetaA,thetadA, ‘black’) %analytical solution for thetad(theta)
xlabel(‘Angular Position (rad) or time (t)’)
ylabel(‘Angular Velocity (rad/sec)’)
% % DETERMINE NUMERICALLY:
% 1) The angular velocity and angular position of the mass about point C
% as a function of time by integration of the equation of motion, thetadd
% 2) The tension in the string as a function of time.
function ds = eom(t,s) %S is current states – vector of current position and vel
%Givens:
theta0 = -pi/6;
m = 2;
g = 9.81;
r = 0.5;
syms Tens
ds(1,1) = sqrt((Tens-m*g*cos(s(1)))/(m*r)); % Derivative of position (s(1) = thetad
ds(2,1) = (-g*sin(s(1)))/r; % Derivative of velocity = thetadd
end
[T,S] = ode45(@eom,linspace(0,2,101),[0,0]); eom, ode45, code, error MATLAB Answers — New Questions
How to compute distortion percentage using radial distortion coefficients
I am planning to calculate the distortion present in the image using radial distortion coefficients obtained using 3d simulation camera,will you please let me know how to compute it.I am planning to calculate the distortion present in the image using radial distortion coefficients obtained using 3d simulation camera,will you please let me know how to compute it. I am planning to calculate the distortion present in the image using radial distortion coefficients obtained using 3d simulation camera,will you please let me know how to compute it. distortion calculation MATLAB Answers — New Questions
I want solution to handle this error listed below and get output
i got this error while simulating how to handle this please help me out
Derivative of state ‘1’ in block ‘flowermodelmppt/PV Array/Diode Rsh/BAL/Transfer Fcn’ at time 7.5E-7 is not finite. The simulation will be stopped. There may be a singularity in the solution. If not, try reducing the step size (either by reducing the fixed step size or by tightening the error tolerances)i got this error while simulating how to handle this please help me out
Derivative of state ‘1’ in block ‘flowermodelmppt/PV Array/Diode Rsh/BAL/Transfer Fcn’ at time 7.5E-7 is not finite. The simulation will be stopped. There may be a singularity in the solution. If not, try reducing the step size (either by reducing the fixed step size or by tightening the error tolerances) i got this error while simulating how to handle this please help me out
Derivative of state ‘1’ in block ‘flowermodelmppt/PV Array/Diode Rsh/BAL/Transfer Fcn’ at time 7.5E-7 is not finite. The simulation will be stopped. There may be a singularity in the solution. If not, try reducing the step size (either by reducing the fixed step size or by tightening the error tolerances) deravative MATLAB Answers — New Questions
simspace multibody in solid dosnt save any file on my computer
Hello so i followed the instrucrtions and i have the link in solidwork enabled i get the message that "simscape multibody link export completer" but the is no xml file in the folder i save or anywhere on my pc in addition the matlab opens a commend window that says
"To get started, type doc.
For product information, visit www.mathworks.com."
what do i do ?
»Hello so i followed the instrucrtions and i have the link in solidwork enabled i get the message that "simscape multibody link export completer" but the is no xml file in the folder i save or anywhere on my pc in addition the matlab opens a commend window that says
"To get started, type doc.
For product information, visit www.mathworks.com."
what do i do ?
» Hello so i followed the instrucrtions and i have the link in solidwork enabled i get the message that "simscape multibody link export completer" but the is no xml file in the folder i save or anywhere on my pc in addition the matlab opens a commend window that says
"To get started, type doc.
For product information, visit www.mathworks.com."
what do i do ?
» simscape, matlab MATLAB Answers — New Questions
The procedure entry point ?xxxx@@YAXHAEAVmwarray@AEBV1@ could not be located in the dynamic libarary xxx
Hello,
I am receiving the following error when I try to use the DLL file I compiled:
"The procedure entry point ?xxxx@@YAXHAEAVmwarray@AEBV1@ could not be located in the dynamic library xxx"
I am using deployTool GUI to compile my m file
My executable ap calling the compiled DLL is compiled using Visual Studio C++ 2017 (VS 2017. community edition):
>> mbuild -setup
MBUILD configured to use ‘Microsoft Visual C++ 2017 (C)’ for C language compilation.
The path to Matlab in Windows 10, is set to be
C:Program FilesMATLABR2024a
Since the error message mentions mwarray, do I have to use an extra compilation switch for mbuild in deployTool?
Thank you.Hello,
I am receiving the following error when I try to use the DLL file I compiled:
"The procedure entry point ?xxxx@@YAXHAEAVmwarray@AEBV1@ could not be located in the dynamic library xxx"
I am using deployTool GUI to compile my m file
My executable ap calling the compiled DLL is compiled using Visual Studio C++ 2017 (VS 2017. community edition):
>> mbuild -setup
MBUILD configured to use ‘Microsoft Visual C++ 2017 (C)’ for C language compilation.
The path to Matlab in Windows 10, is set to be
C:Program FilesMATLABR2024a
Since the error message mentions mwarray, do I have to use an extra compilation switch for mbuild in deployTool?
Thank you. Hello,
I am receiving the following error when I try to use the DLL file I compiled:
"The procedure entry point ?xxxx@@YAXHAEAVmwarray@AEBV1@ could not be located in the dynamic library xxx"
I am using deployTool GUI to compile my m file
My executable ap calling the compiled DLL is compiled using Visual Studio C++ 2017 (VS 2017. community edition):
>> mbuild -setup
MBUILD configured to use ‘Microsoft Visual C++ 2017 (C)’ for C language compilation.
The path to Matlab in Windows 10, is set to be
C:Program FilesMATLABR2024a
Since the error message mentions mwarray, do I have to use an extra compilation switch for mbuild in deployTool?
Thank you. matlab compiler, mbuild MATLAB Answers — New Questions
Need to open matrix data from IR Camera recording. Wanting to get data translated into excel format for running a python script for analysis.
We recorded a 10 minute period using MatLab Image Acquisition Tool through an IR camera watching for natural convection in a steady state object. We’re needing to translate temperature data from each frame into a form of storing that data in which we can implement code to look for signs of natural convection. Currently, matlab says the file is too large to open in a matrix view. However, manually getting pixel information for each pixel needed over each slide is just not possibleWe recorded a 10 minute period using MatLab Image Acquisition Tool through an IR camera watching for natural convection in a steady state object. We’re needing to translate temperature data from each frame into a form of storing that data in which we can implement code to look for signs of natural convection. Currently, matlab says the file is too large to open in a matrix view. However, manually getting pixel information for each pixel needed over each slide is just not possible We recorded a 10 minute period using MatLab Image Acquisition Tool through an IR camera watching for natural convection in a steady state object. We’re needing to translate temperature data from each frame into a form of storing that data in which we can implement code to look for signs of natural convection. Currently, matlab says the file is too large to open in a matrix view. However, manually getting pixel information for each pixel needed over each slide is just not possible image acquisition, matrix data MATLAB Answers — New Questions
Is NPRACH Detection Example available only on R2024 version?
Is NPRACH Detection Example available only on R2024 version?Is NPRACH Detection Example available only on R2024 version? Is NPRACH Detection Example available only on R2024 version? lte toolbox, nb-iot, matlab, commnunication toolbox MATLAB Answers — New Questions
How i modified the code so Kb start form Kb_min for first phase but after that it start at Kb_Max . Kindly guide me
How i modified the code so Kb start form Kb_min for first phase but after that it start at Kb_Max . Kindly guide me
type TestCode1.mHow i modified the code so Kb start form Kb_min for first phase but after that it start at Kb_Max . Kindly guide me
type TestCode1.m How i modified the code so Kb start form Kb_min for first phase but after that it start at Kb_Max . Kindly guide me
type TestCode1.m matlab code MATLAB Answers — New Questions
An efficient way to round decimal numbers up to the n-decimal in a cell array
eIs there an efficient way to round decimal numbers up to the n-decimal in a cell array?
In the following example, I would like to round the decimal numbers up to n=2, i.e. to the second decimal:
a = [
{[ 0.235089379668094 0]}
{[0.0793405810870535 0]}
{[ 0.142843392632868 0]}
{[ 0.639081029130393 0]}
{[ 0.970756532033504 0]}
{[ 1 0]}]
My desired output would be the following one:
a = [
{[0.24 0]}
{[0.08 0]}
{[0.14 0]}
{[0.64 0]}
{[0.97 0]}
{[ 1 0]}]eIs there an efficient way to round decimal numbers up to the n-decimal in a cell array?
In the following example, I would like to round the decimal numbers up to n=2, i.e. to the second decimal:
a = [
{[ 0.235089379668094 0]}
{[0.0793405810870535 0]}
{[ 0.142843392632868 0]}
{[ 0.639081029130393 0]}
{[ 0.970756532033504 0]}
{[ 1 0]}]
My desired output would be the following one:
a = [
{[0.24 0]}
{[0.08 0]}
{[0.14 0]}
{[0.64 0]}
{[0.97 0]}
{[ 1 0]}] eIs there an efficient way to round decimal numbers up to the n-decimal in a cell array?
In the following example, I would like to round the decimal numbers up to n=2, i.e. to the second decimal:
a = [
{[ 0.235089379668094 0]}
{[0.0793405810870535 0]}
{[ 0.142843392632868 0]}
{[ 0.639081029130393 0]}
{[ 0.970756532033504 0]}
{[ 1 0]}]
My desired output would be the following one:
a = [
{[0.24 0]}
{[0.08 0]}
{[0.14 0]}
{[0.64 0]}
{[0.97 0]}
{[ 1 0]}] round, decimal, cell, array MATLAB Answers — New Questions
Generation of SPWM waveform with dead-time for a new circuit topology inverter using MATLAB
Hello MathWorks Community,
I am currently working on a project where I need to generate a Sinusoidal Pulse Width Modulation (SPWM) waveform that includes dead-time for a new inverter circuit topology. I intend to use MATLAB for this task, but I am having difficulty figuring out how to get started.
An important aspect of this problem is that the reference signal (sinusoidal) I want to use is not the typical M*sin(ωt), but rather (1/(2-M*sin(ωt))). I would appreciate if you could consider this when giving me advice on how to proceed.
Does MATLAB have built-in functions that can be used for generating such SPWM waveforms? If so, what are these functions and how can they be utilized effectively? Also, are there any recommended methods for handling the dead-time and the peculiar reference waveform in this context?
If you have examples or tutorials that are closely related to this problem, I would be very grateful if you could share them.
Thank you in advance for your support.Hello MathWorks Community,
I am currently working on a project where I need to generate a Sinusoidal Pulse Width Modulation (SPWM) waveform that includes dead-time for a new inverter circuit topology. I intend to use MATLAB for this task, but I am having difficulty figuring out how to get started.
An important aspect of this problem is that the reference signal (sinusoidal) I want to use is not the typical M*sin(ωt), but rather (1/(2-M*sin(ωt))). I would appreciate if you could consider this when giving me advice on how to proceed.
Does MATLAB have built-in functions that can be used for generating such SPWM waveforms? If so, what are these functions and how can they be utilized effectively? Also, are there any recommended methods for handling the dead-time and the peculiar reference waveform in this context?
If you have examples or tutorials that are closely related to this problem, I would be very grateful if you could share them.
Thank you in advance for your support. Hello MathWorks Community,
I am currently working on a project where I need to generate a Sinusoidal Pulse Width Modulation (SPWM) waveform that includes dead-time for a new inverter circuit topology. I intend to use MATLAB for this task, but I am having difficulty figuring out how to get started.
An important aspect of this problem is that the reference signal (sinusoidal) I want to use is not the typical M*sin(ωt), but rather (1/(2-M*sin(ωt))). I would appreciate if you could consider this when giving me advice on how to proceed.
Does MATLAB have built-in functions that can be used for generating such SPWM waveforms? If so, what are these functions and how can they be utilized effectively? Also, are there any recommended methods for handling the dead-time and the peculiar reference waveform in this context?
If you have examples or tutorials that are closely related to this problem, I would be very grateful if you could share them.
Thank you in advance for your support. matlab, spwm, dead-time, inverter, circuit topology, waveform generation MATLAB Answers — New Questions
Matlab Runtime (mcr) new features
I am making a research about the differences, new features, between the MCR versions of 2019(9.6) and 2024(24.1). But I couldn’t find any appropriate website or documentation about it. I need to learn what is new on the current version of MCR. Can you give me a link or anything that can help. Thanks.I am making a research about the differences, new features, between the MCR versions of 2019(9.6) and 2024(24.1). But I couldn’t find any appropriate website or documentation about it. I need to learn what is new on the current version of MCR. Can you give me a link or anything that can help. Thanks. I am making a research about the differences, new features, between the MCR versions of 2019(9.6) and 2024(24.1). But I couldn’t find any appropriate website or documentation about it. I need to learn what is new on the current version of MCR. Can you give me a link or anything that can help. Thanks. #matlabruntime #mcr MATLAB Answers — New Questions
DFT and FFT of Image
Shift the Fourier transform so that it is centered around the middle of your figure and plot the
absolute value of the shifted DFT. Then apply the log transform (log(1 + |DFT|))
and plot your result.
I know that I’m supposed to use fft2 and fftshift. I have the image and this is the code I have this far.
>> X = imread(‘granular_media.jpg’);
>> X1 = double(X(501:700,1401:1600));
>> X2 = double(X(1:200,1:200));
I need to first compute the DFT of the 200×200 subimages that I created. Any help with this?Shift the Fourier transform so that it is centered around the middle of your figure and plot the
absolute value of the shifted DFT. Then apply the log transform (log(1 + |DFT|))
and plot your result.
I know that I’m supposed to use fft2 and fftshift. I have the image and this is the code I have this far.
>> X = imread(‘granular_media.jpg’);
>> X1 = double(X(501:700,1401:1600));
>> X2 = double(X(1:200,1:200));
I need to first compute the DFT of the 200×200 subimages that I created. Any help with this? Shift the Fourier transform so that it is centered around the middle of your figure and plot the
absolute value of the shifted DFT. Then apply the log transform (log(1 + |DFT|))
and plot your result.
I know that I’m supposed to use fft2 and fftshift. I have the image and this is the code I have this far.
>> X = imread(‘granular_media.jpg’);
>> X1 = double(X(501:700,1401:1600));
>> X2 = double(X(1:200,1:200));
I need to first compute the DFT of the 200×200 subimages that I created. Any help with this? image MATLAB Answers — New Questions
Bayesian Optimization in real-time with Simulink and Code Generation
For a particular application, I need to implement Bayesian Optimization so to continuously run in a Simulink model. The simulink model is a control algorithm, which has to be translated into C code, and run on an ECU. The Bayesian Optimization should update the controller parameters (which are the parameters to be optimized) based on a certain cost function, which is directly measured from some sensors available to the ECU. So in practice my cost function should "wait" for a flag "experiment completed" coming from the simulink model; after the flag is generated, the cost function is evaluated based on the data.
More in details, the algorithm idea is something like this:
Perform the experiment by using a certain set of parameters.
After the experiment is done, the cost function for that set of parameters can be evaluated.
Run an iteration of bayesopt() and update the GP model, etc. A new set of parameters is selected through acquisition function.
The experiment is then performed again, and the new cost function is evaluated, and so on…
Now, I know that I can’t directly use bayesopt() in code generation. Is there a way to do this without having to completely rewrite the code for the Bayesian Optimization?For a particular application, I need to implement Bayesian Optimization so to continuously run in a Simulink model. The simulink model is a control algorithm, which has to be translated into C code, and run on an ECU. The Bayesian Optimization should update the controller parameters (which are the parameters to be optimized) based on a certain cost function, which is directly measured from some sensors available to the ECU. So in practice my cost function should "wait" for a flag "experiment completed" coming from the simulink model; after the flag is generated, the cost function is evaluated based on the data.
More in details, the algorithm idea is something like this:
Perform the experiment by using a certain set of parameters.
After the experiment is done, the cost function for that set of parameters can be evaluated.
Run an iteration of bayesopt() and update the GP model, etc. A new set of parameters is selected through acquisition function.
The experiment is then performed again, and the new cost function is evaluated, and so on…
Now, I know that I can’t directly use bayesopt() in code generation. Is there a way to do this without having to completely rewrite the code for the Bayesian Optimization? For a particular application, I need to implement Bayesian Optimization so to continuously run in a Simulink model. The simulink model is a control algorithm, which has to be translated into C code, and run on an ECU. The Bayesian Optimization should update the controller parameters (which are the parameters to be optimized) based on a certain cost function, which is directly measured from some sensors available to the ECU. So in practice my cost function should "wait" for a flag "experiment completed" coming from the simulink model; after the flag is generated, the cost function is evaluated based on the data.
More in details, the algorithm idea is something like this:
Perform the experiment by using a certain set of parameters.
After the experiment is done, the cost function for that set of parameters can be evaluated.
Run an iteration of bayesopt() and update the GP model, etc. A new set of parameters is selected through acquisition function.
The experiment is then performed again, and the new cost function is evaluated, and so on…
Now, I know that I can’t directly use bayesopt() in code generation. Is there a way to do this without having to completely rewrite the code for the Bayesian Optimization? control, optimization, code generation MATLAB Answers — New Questions