Tag Archives: matlab
Chapter and section number is not increased in report generator.
Chapter and section number is not increased in report generator.
I use mlreportgen.report, mlerportgen.dom class.Chapter and section number is not increased in report generator.
I use mlreportgen.report, mlerportgen.dom class. Chapter and section number is not increased in report generator.
I use mlreportgen.report, mlerportgen.dom class. simulink, report generator, mlreportgen MATLAB Answers — New Questions
Error in save to mat file
I have got following error while saving the agent for a DQN-RL problem. The error doesnt pop-up always, however, most of the time the saved .mat file is corrupt Similar problem in another PC too. Both the PC is having enough space in the HDD and of 64GB RAM. Sometimes it saves successfully with each MAT file of 1GB size,otherwise, the corrupted MAT files are in KBs.
Version: MATLAB 2021a
Error:
Error using save
Unable to save file ‘C:UsersDocumentsMATLAB 2021initial_agent.mat’. The file could not be closed, and might now be corrupt.
Error in DQN__Training (line 101)
save("initial_agent","agent")I have got following error while saving the agent for a DQN-RL problem. The error doesnt pop-up always, however, most of the time the saved .mat file is corrupt Similar problem in another PC too. Both the PC is having enough space in the HDD and of 64GB RAM. Sometimes it saves successfully with each MAT file of 1GB size,otherwise, the corrupted MAT files are in KBs.
Version: MATLAB 2021a
Error:
Error using save
Unable to save file ‘C:UsersDocumentsMATLAB 2021initial_agent.mat’. The file could not be closed, and might now be corrupt.
Error in DQN__Training (line 101)
save("initial_agent","agent") I have got following error while saving the agent for a DQN-RL problem. The error doesnt pop-up always, however, most of the time the saved .mat file is corrupt Similar problem in another PC too. Both the PC is having enough space in the HDD and of 64GB RAM. Sometimes it saves successfully with each MAT file of 1GB size,otherwise, the corrupted MAT files are in KBs.
Version: MATLAB 2021a
Error:
Error using save
Unable to save file ‘C:UsersDocumentsMATLAB 2021initial_agent.mat’. The file could not be closed, and might now be corrupt.
Error in DQN__Training (line 101)
save("initial_agent","agent") save MATLAB Answers — New Questions
Segregating an EMG signal based on activation
Hi everyone,
I have two arrays, one of which stores EMG readings in mV from a hand and the second storing time in seconds. I have plotted these against eachother and am now trying to segregate the signal into separate cycles. I want to segragate the signal from the start of 1 activity to the beginning of the next activation (please see attached photo). Please could you give me any ideas of how I might do this.
Thanks,Hi everyone,
I have two arrays, one of which stores EMG readings in mV from a hand and the second storing time in seconds. I have plotted these against eachother and am now trying to segregate the signal into separate cycles. I want to segragate the signal from the start of 1 activity to the beginning of the next activation (please see attached photo). Please could you give me any ideas of how I might do this.
Thanks, Hi everyone,
I have two arrays, one of which stores EMG readings in mV from a hand and the second storing time in seconds. I have plotted these against eachother and am now trying to segregate the signal into separate cycles. I want to segragate the signal from the start of 1 activity to the beginning of the next activation (please see attached photo). Please could you give me any ideas of how I might do this.
Thanks, emg, signal processing MATLAB Answers — New Questions
Replicate the Event-Driven Task in External Mode
I am trying to replicate the simulation results of the event-driven task in external mode. I ran in R2022a. My board is Zedboard. The solver is in fixed step.
After building and running it, it has several warnings, including
Saving external mode simulation output as a single object is not supported because the workspace variable ‘out’ is not created during model code execution. To suppress the warning, set ‘ReturnWorkspaceOutputs’ to ‘off’.
No data has been selected for uploading.
When I open Data Inspector, the processed data is always zero. How to make the process data to generate the results like simulation?I am trying to replicate the simulation results of the event-driven task in external mode. I ran in R2022a. My board is Zedboard. The solver is in fixed step.
After building and running it, it has several warnings, including
Saving external mode simulation output as a single object is not supported because the workspace variable ‘out’ is not created during model code execution. To suppress the warning, set ‘ReturnWorkspaceOutputs’ to ‘off’.
No data has been selected for uploading.
When I open Data Inspector, the processed data is always zero. How to make the process data to generate the results like simulation? I am trying to replicate the simulation results of the event-driven task in external mode. I ran in R2022a. My board is Zedboard. The solver is in fixed step.
After building and running it, it has several warnings, including
Saving external mode simulation output as a single object is not supported because the workspace variable ‘out’ is not created during model code execution. To suppress the warning, set ‘ReturnWorkspaceOutputs’ to ‘off’.
No data has been selected for uploading.
When I open Data Inspector, the processed data is always zero. How to make the process data to generate the results like simulation? external mode, event-driven task MATLAB Answers — New Questions
test test test test
testtest test testing test, testing test s MATLAB Answers — New Questions
AD-FMCOMMS5 and ZC702 MATLAB Support
Hi,
We are currently conducting a adaptive null steering/beamforming project and decided to use AD-FMCOMMS5 and ZC706 due to direct MathWorks integration support. During first phase we want to capture RF data and post-process it in MATLAB. ZC706 is now obsolete and that leads us to use different SoC boards like ZC702.
There is a uncertainty about AD-FMCOMMS5 and ZC702, in particular topics MATLAB staff says this system "potentially" works but in other topics people say these boards are not supported for MathWorks integration.
Is there any way that i get direct approval about AD-FMCOMMS5 and ZC702 integration with Mathworks from MATLAB staff or researchers ?
Thanks.Hi,
We are currently conducting a adaptive null steering/beamforming project and decided to use AD-FMCOMMS5 and ZC706 due to direct MathWorks integration support. During first phase we want to capture RF data and post-process it in MATLAB. ZC706 is now obsolete and that leads us to use different SoC boards like ZC702.
There is a uncertainty about AD-FMCOMMS5 and ZC702, in particular topics MATLAB staff says this system "potentially" works but in other topics people say these boards are not supported for MathWorks integration.
Is there any way that i get direct approval about AD-FMCOMMS5 and ZC702 integration with Mathworks from MATLAB staff or researchers ?
Thanks. Hi,
We are currently conducting a adaptive null steering/beamforming project and decided to use AD-FMCOMMS5 and ZC706 due to direct MathWorks integration support. During first phase we want to capture RF data and post-process it in MATLAB. ZC706 is now obsolete and that leads us to use different SoC boards like ZC702.
There is a uncertainty about AD-FMCOMMS5 and ZC702, in particular topics MATLAB staff says this system "potentially" works but in other topics people say these boards are not supported for MathWorks integration.
Is there any way that i get direct approval about AD-FMCOMMS5 and ZC702 integration with Mathworks from MATLAB staff or researchers ?
Thanks. beamforming, null steering, zynq, zc702, zc706, soc, fmcomms5, ad-fmcomms5 MATLAB Answers — New Questions
how to display (3000x4000x4) matrix as image in matlab
I have created a 3000x4000x4 matrix in matlab, when I try to use image() function to display it as a picture, matlab told me image() function could only display m*n or m*n*3 matrix. So how could I display m*n*4 matrix as a picture? Many thanks.I have created a 3000x4000x4 matrix in matlab, when I try to use image() function to display it as a picture, matlab told me image() function could only display m*n or m*n*3 matrix. So how could I display m*n*4 matrix as a picture? Many thanks. I have created a 3000x4000x4 matrix in matlab, when I try to use image() function to display it as a picture, matlab told me image() function could only display m*n or m*n*3 matrix. So how could I display m*n*4 matrix as a picture? Many thanks. display m*n*4 matrix as a image MATLAB Answers — New Questions
name mismatch error when build the model using embedded coder
when I build the model I get the name mismatch error for two calibratable signals . The signals are in the data dictionary , and I use them in the model by pulling from the dd with the same name . can anyone point me out what possibly cause this error?when I build the model I get the name mismatch error for two calibratable signals . The signals are in the data dictionary , and I use them in the model by pulling from the dd with the same name . can anyone point me out what possibly cause this error? when I build the model I get the name mismatch error for two calibratable signals . The signals are in the data dictionary , and I use them in the model by pulling from the dd with the same name . can anyone point me out what possibly cause this error? simulink, embedded coder, build model MATLAB Answers — New Questions
Writing legends for MATLAB figures with subscripts
What is the solution for writing legends for MATLAB figures with subscripts?What is the solution for writing legends for MATLAB figures with subscripts? What is the solution for writing legends for MATLAB figures with subscripts? figure, legend, subscript MATLAB Answers — New Questions
Extraction of the spatial coordinates of a curve and calculation of the normal line to each of its points
Hello everyone
I have the following dataset: https://www.dropbox.com/scl/fo/3dthvtj2ex9gmhsu3lkrq/AJt2KVYls3YM89v5SRmSEWk?rlkey=r63d0ej2sv7ku8i4ardla5pvi&dl=0, which gives rise to the data on the panel mz of the figure below:
My idea is to extract the (a,b) set of points that define the whole right side of the whitish curve. Once that it is done, I will need to extract, for each of the points of this curve, the normal line along the track (that it is, the (a,b) coordinates together with the corresponding values of the mz values).
Any ideas on how to do this efficiently?
Additional information (September 3, 2024)
When I talk about the normal to the tangent at each point of the curve mz, I am thinking about something like this:
where the green X symbol corresponds to a certain point of the curve, the black line to the tangent to the curve at that specific (x,y) point, and the dashed yellow line refers to the normal to the tangent line that (x,y) point. I would be interested in extracting the mz value all along that normal line inside the boundaries of the sample. So I would say that some grid data process would be important to make if not too many points actually exist in the given data set.Hello everyone
I have the following dataset: https://www.dropbox.com/scl/fo/3dthvtj2ex9gmhsu3lkrq/AJt2KVYls3YM89v5SRmSEWk?rlkey=r63d0ej2sv7ku8i4ardla5pvi&dl=0, which gives rise to the data on the panel mz of the figure below:
My idea is to extract the (a,b) set of points that define the whole right side of the whitish curve. Once that it is done, I will need to extract, for each of the points of this curve, the normal line along the track (that it is, the (a,b) coordinates together with the corresponding values of the mz values).
Any ideas on how to do this efficiently?
Additional information (September 3, 2024)
When I talk about the normal to the tangent at each point of the curve mz, I am thinking about something like this:
where the green X symbol corresponds to a certain point of the curve, the black line to the tangent to the curve at that specific (x,y) point, and the dashed yellow line refers to the normal to the tangent line that (x,y) point. I would be interested in extracting the mz value all along that normal line inside the boundaries of the sample. So I would say that some grid data process would be important to make if not too many points actually exist in the given data set. Hello everyone
I have the following dataset: https://www.dropbox.com/scl/fo/3dthvtj2ex9gmhsu3lkrq/AJt2KVYls3YM89v5SRmSEWk?rlkey=r63d0ej2sv7ku8i4ardla5pvi&dl=0, which gives rise to the data on the panel mz of the figure below:
My idea is to extract the (a,b) set of points that define the whole right side of the whitish curve. Once that it is done, I will need to extract, for each of the points of this curve, the normal line along the track (that it is, the (a,b) coordinates together with the corresponding values of the mz values).
Any ideas on how to do this efficiently?
Additional information (September 3, 2024)
When I talk about the normal to the tangent at each point of the curve mz, I am thinking about something like this:
where the green X symbol corresponds to a certain point of the curve, the black line to the tangent to the curve at that specific (x,y) point, and the dashed yellow line refers to the normal to the tangent line that (x,y) point. I would be interested in extracting the mz value all along that normal line inside the boundaries of the sample. So I would say that some grid data process would be important to make if not too many points actually exist in the given data set. data pattern extraction, normal lines to a curve MATLAB Answers — New Questions
(Enhancement Request)vision.VideoPlayer should be presented as a more modern player
In the past two years, MATHWORKS has updated the image viewer and audio viewer, giving them a more modern interface with features like play, pause, fast forward, and some interactive tools that are more commonly found in typical third-party players. However, the video player has not seen any updates. For instance, the vision.VideoPlayer could benefit from a more modern player interface. Perhaps I haven’t found a suitable built-in player yet. It would be great if there were support for custom image processing and audio processing algorithms that could be played in a more modern interface in real time.
Additionally, I found it quite challenging to develop a modern video player from scratch in App Designer.
—————————————————————————————————————–
BTW,the following picture shows the built-in function uihtml function showing a more modern playback interface with controls for play, pause and so on. But can not add real-time image processing algorithms.In the past two years, MATHWORKS has updated the image viewer and audio viewer, giving them a more modern interface with features like play, pause, fast forward, and some interactive tools that are more commonly found in typical third-party players. However, the video player has not seen any updates. For instance, the vision.VideoPlayer could benefit from a more modern player interface. Perhaps I haven’t found a suitable built-in player yet. It would be great if there were support for custom image processing and audio processing algorithms that could be played in a more modern interface in real time.
Additionally, I found it quite challenging to develop a modern video player from scratch in App Designer.
—————————————————————————————————————–
BTW,the following picture shows the built-in function uihtml function showing a more modern playback interface with controls for play, pause and so on. But can not add real-time image processing algorithms. In the past two years, MATHWORKS has updated the image viewer and audio viewer, giving them a more modern interface with features like play, pause, fast forward, and some interactive tools that are more commonly found in typical third-party players. However, the video player has not seen any updates. For instance, the vision.VideoPlayer could benefit from a more modern player interface. Perhaps I haven’t found a suitable built-in player yet. It would be great if there were support for custom image processing and audio processing algorithms that could be played in a more modern interface in real time.
Additionally, I found it quite challenging to develop a modern video player from scratch in App Designer.
—————————————————————————————————————–
BTW,the following picture shows the built-in function uihtml function showing a more modern playback interface with controls for play, pause and so on. But can not add real-time image processing algorithms. video player, image processing, computer vision, appdesigner MATLAB Answers — New Questions
Phase Plots Dropping when quadrant changes
I am trying to plot the phase of a vibratory system with base excitation. I did the magnitude, but the phase is giving me problems. How can I make my equations so the phase equations are continuous and do not suddenly drop when the quadrant changes? atan2d does not show up with anything. Using atand shows the below result:
It should look something the phase plot on the top right of this:
Heres my code:I am trying to plot the phase of a vibratory system with base excitation. I did the magnitude, but the phase is giving me problems. How can I make my equations so the phase equations are continuous and do not suddenly drop when the quadrant changes? atan2d does not show up with anything. Using atand shows the below result:
It should look something the phase plot on the top right of this:
Heres my code: I am trying to plot the phase of a vibratory system with base excitation. I did the magnitude, but the phase is giving me problems. How can I make my equations so the phase equations are continuous and do not suddenly drop when the quadrant changes? atan2d does not show up with anything. Using atand shows the below result:
It should look something the phase plot on the top right of this:
Heres my code: phase, vibrations, matlab MATLAB Answers — New Questions
I have a set of .mat files with random names. I want to import all those files from the directory using loop. Each file has 4 columns and I want to vertically concatenate each column from all the imported files. Please help with the code.
I have a set of .mat files with random names. I want to import all those files from the directory using loop. Each file has 4 columns and I want to vertically concatenate each column from all the imported files. Please help with the code.I have a set of .mat files with random names. I want to import all those files from the directory using loop. Each file has 4 columns and I want to vertically concatenate each column from all the imported files. Please help with the code. I have a set of .mat files with random names. I want to import all those files from the directory using loop. Each file has 4 columns and I want to vertically concatenate each column from all the imported files. Please help with the code. multiple file import, concatenate MATLAB Answers — New Questions
How to correctly adjust the FaceColor property of patch objects in a figure with a legend?
Hello community,
I am having an issue adjusting the FaceColor property of patch objects in a figure. That is, only the legend is updated when I try to change the color of a patch object. My issue can be replicated with the code below:
% Load the figure
openfig(‘cylinder.fig’);
The figure contains four patch objects combined to form a cylindrical shape. The figure also contains a legend.
When I save the patch objects to the variable patches I do not receive any errors:
% Get all patch objects in the figure
patches = findobj(gcf,’Type’,’patch’);
disp([‘The number of patch objects is ‘ num2str(length(patches)) ‘.’])
However, when I try to change the face color of one of the patch objects, the color is only changed inside of the legend. For example,
patches(1).FaceColor = ‘r’;
results in the following visual change:
My best guess is that the findobj() function is only identifying the patch objects in the legend and not the objects composing the cylinder, but I am not sure how to confirm this.
My question: Am I making a programmatic mistake? Or is there a bug in how MATLAB is applying the color change operation to the patch object? Thank you in advance for the help!
P.S. I am using MATLAB Online for my problem, in case that makes a difference.Hello community,
I am having an issue adjusting the FaceColor property of patch objects in a figure. That is, only the legend is updated when I try to change the color of a patch object. My issue can be replicated with the code below:
% Load the figure
openfig(‘cylinder.fig’);
The figure contains four patch objects combined to form a cylindrical shape. The figure also contains a legend.
When I save the patch objects to the variable patches I do not receive any errors:
% Get all patch objects in the figure
patches = findobj(gcf,’Type’,’patch’);
disp([‘The number of patch objects is ‘ num2str(length(patches)) ‘.’])
However, when I try to change the face color of one of the patch objects, the color is only changed inside of the legend. For example,
patches(1).FaceColor = ‘r’;
results in the following visual change:
My best guess is that the findobj() function is only identifying the patch objects in the legend and not the objects composing the cylinder, but I am not sure how to confirm this.
My question: Am I making a programmatic mistake? Or is there a bug in how MATLAB is applying the color change operation to the patch object? Thank you in advance for the help!
P.S. I am using MATLAB Online for my problem, in case that makes a difference. Hello community,
I am having an issue adjusting the FaceColor property of patch objects in a figure. That is, only the legend is updated when I try to change the color of a patch object. My issue can be replicated with the code below:
% Load the figure
openfig(‘cylinder.fig’);
The figure contains four patch objects combined to form a cylindrical shape. The figure also contains a legend.
When I save the patch objects to the variable patches I do not receive any errors:
% Get all patch objects in the figure
patches = findobj(gcf,’Type’,’patch’);
disp([‘The number of patch objects is ‘ num2str(length(patches)) ‘.’])
However, when I try to change the face color of one of the patch objects, the color is only changed inside of the legend. For example,
patches(1).FaceColor = ‘r’;
results in the following visual change:
My best guess is that the findobj() function is only identifying the patch objects in the legend and not the objects composing the cylinder, but I am not sure how to confirm this.
My question: Am I making a programmatic mistake? Or is there a bug in how MATLAB is applying the color change operation to the patch object? Thank you in advance for the help!
P.S. I am using MATLAB Online for my problem, in case that makes a difference. plotting MATLAB Answers — New Questions
Why did my code break after adding a class definition?
I have some code that interfaces with external hardware via loadlibrary to a vendor-supplied DLL. After getting everything working the way I wanted, I decided to refactor to make future maintainability easier. As part of this process, I defined a class params.m that holds experimental parameters (e.g. image height, image width, number of frames,…). Previously, I had just made a params struct and added stuff to it as needed (without a class definition). I also added arguments to my function definitions, e.g.:
function configure(inParams, boardNumber)
arguments
inParams (1,1) params
boardNumber (1,1) double {mustBeInteger, mustBePositive}
end
% call hardware functions from DLL
end
In doing so, this broke my experiment. The Matlab code is shared between two systems, one that has a single board and one that has two boards so configure is called in a for loop:
for boardId = 1 : numBoards
configure(inParams,boardId);
end
% do stuff
The code refactor broke my experiment, but only on the system that has two boards. While debugging, I noticed that inserting an arbitrary pause made the two-board system work every other time the code was run (which is better than never, but still 50%). After that realization, I tried commenting out the arguments definition:
function configure(inParams, boardNumber)
% arguments
% inParams (1,1) params
% boardNumber (1,1) double {mustBeInteger, mustBePositive}
% end
% call hardware functions from DLL
end
Which removed the need for the arbitrary pause, but still only got the two-board system to work correctly on every other function call (always works on first try, and from then on any odd-numbered run will work). It seems as though there is some kind of under-the-hood optimization(?) that is ocurring after I added a class definition that breaks things.
Does anyone have other ideas what the issue might be and/or how I can disable optimizations for that one function call (which appears to be impossible based on my reading). I recognize this is an exceptionally odd error and I’m happy to provide more information if that would be useful. I have also reached out to the hardware manufacturer to see if they have any suggestions for what might be causing this.I have some code that interfaces with external hardware via loadlibrary to a vendor-supplied DLL. After getting everything working the way I wanted, I decided to refactor to make future maintainability easier. As part of this process, I defined a class params.m that holds experimental parameters (e.g. image height, image width, number of frames,…). Previously, I had just made a params struct and added stuff to it as needed (without a class definition). I also added arguments to my function definitions, e.g.:
function configure(inParams, boardNumber)
arguments
inParams (1,1) params
boardNumber (1,1) double {mustBeInteger, mustBePositive}
end
% call hardware functions from DLL
end
In doing so, this broke my experiment. The Matlab code is shared between two systems, one that has a single board and one that has two boards so configure is called in a for loop:
for boardId = 1 : numBoards
configure(inParams,boardId);
end
% do stuff
The code refactor broke my experiment, but only on the system that has two boards. While debugging, I noticed that inserting an arbitrary pause made the two-board system work every other time the code was run (which is better than never, but still 50%). After that realization, I tried commenting out the arguments definition:
function configure(inParams, boardNumber)
% arguments
% inParams (1,1) params
% boardNumber (1,1) double {mustBeInteger, mustBePositive}
% end
% call hardware functions from DLL
end
Which removed the need for the arbitrary pause, but still only got the two-board system to work correctly on every other function call (always works on first try, and from then on any odd-numbered run will work). It seems as though there is some kind of under-the-hood optimization(?) that is ocurring after I added a class definition that breaks things.
Does anyone have other ideas what the issue might be and/or how I can disable optimizations for that one function call (which appears to be impossible based on my reading). I recognize this is an exceptionally odd error and I’m happy to provide more information if that would be useful. I have also reached out to the hardware manufacturer to see if they have any suggestions for what might be causing this. I have some code that interfaces with external hardware via loadlibrary to a vendor-supplied DLL. After getting everything working the way I wanted, I decided to refactor to make future maintainability easier. As part of this process, I defined a class params.m that holds experimental parameters (e.g. image height, image width, number of frames,…). Previously, I had just made a params struct and added stuff to it as needed (without a class definition). I also added arguments to my function definitions, e.g.:
function configure(inParams, boardNumber)
arguments
inParams (1,1) params
boardNumber (1,1) double {mustBeInteger, mustBePositive}
end
% call hardware functions from DLL
end
In doing so, this broke my experiment. The Matlab code is shared between two systems, one that has a single board and one that has two boards so configure is called in a for loop:
for boardId = 1 : numBoards
configure(inParams,boardId);
end
% do stuff
The code refactor broke my experiment, but only on the system that has two boards. While debugging, I noticed that inserting an arbitrary pause made the two-board system work every other time the code was run (which is better than never, but still 50%). After that realization, I tried commenting out the arguments definition:
function configure(inParams, boardNumber)
% arguments
% inParams (1,1) params
% boardNumber (1,1) double {mustBeInteger, mustBePositive}
% end
% call hardware functions from DLL
end
Which removed the need for the arbitrary pause, but still only got the two-board system to work correctly on every other function call (always works on first try, and from then on any odd-numbered run will work). It seems as though there is some kind of under-the-hood optimization(?) that is ocurring after I added a class definition that breaks things.
Does anyone have other ideas what the issue might be and/or how I can disable optimizations for that one function call (which appears to be impossible based on my reading). I recognize this is an exceptionally odd error and I’m happy to provide more information if that would be useful. I have also reached out to the hardware manufacturer to see if they have any suggestions for what might be causing this. jit, class, for loop, performance MATLAB Answers — New Questions
Matlab code to find the Wave height
I want to find the water wave height and wave length by analysing the video. I write the code for that :
Is this correct?
videoFile = ‘wave_video.mp4’; % Replace with your video file name
video = VideoReader(videoFile);
numFrames = floor(video.Duration * video.FrameRate);
frameRate = video.FrameRate;
displacement = zeros(1, numFrames);
% Define a threshold value for detecting the wave (adjust this as needed)
threshold = 100;
for k = 1:numFrames
frame = readFrame(video);
grayFrame = rgb2gray(frame);
% Threshold the grayscale image to create a binary mask
binaryImage = grayFrame > threshold;
% Sum the binary image to get an estimation of the wave’s displacement
displacement(k) = sum(binaryImage(:));
end
time = (0:numFrames-1) / frameRate;
plot(time, displacement);
xlabel(‘Time (s)’);
ylabel(‘Displacement’);
title(‘Water Wave Displacement Over Time’);
How to find the unit of that height.I want to find the water wave height and wave length by analysing the video. I write the code for that :
Is this correct?
videoFile = ‘wave_video.mp4’; % Replace with your video file name
video = VideoReader(videoFile);
numFrames = floor(video.Duration * video.FrameRate);
frameRate = video.FrameRate;
displacement = zeros(1, numFrames);
% Define a threshold value for detecting the wave (adjust this as needed)
threshold = 100;
for k = 1:numFrames
frame = readFrame(video);
grayFrame = rgb2gray(frame);
% Threshold the grayscale image to create a binary mask
binaryImage = grayFrame > threshold;
% Sum the binary image to get an estimation of the wave’s displacement
displacement(k) = sum(binaryImage(:));
end
time = (0:numFrames-1) / frameRate;
plot(time, displacement);
xlabel(‘Time (s)’);
ylabel(‘Displacement’);
title(‘Water Wave Displacement Over Time’);
How to find the unit of that height. I want to find the water wave height and wave length by analysing the video. I write the code for that :
Is this correct?
videoFile = ‘wave_video.mp4’; % Replace with your video file name
video = VideoReader(videoFile);
numFrames = floor(video.Duration * video.FrameRate);
frameRate = video.FrameRate;
displacement = zeros(1, numFrames);
% Define a threshold value for detecting the wave (adjust this as needed)
threshold = 100;
for k = 1:numFrames
frame = readFrame(video);
grayFrame = rgb2gray(frame);
% Threshold the grayscale image to create a binary mask
binaryImage = grayFrame > threshold;
% Sum the binary image to get an estimation of the wave’s displacement
displacement(k) = sum(binaryImage(:));
end
time = (0:numFrames-1) / frameRate;
plot(time, displacement);
xlabel(‘Time (s)’);
ylabel(‘Displacement’);
title(‘Water Wave Displacement Over Time’);
How to find the unit of that height. matlab, water wave, wave height MATLAB Answers — New Questions
IMCLIPBOARD in R2025a
Hi everyone,
I really like IMCLIPBOARD. I think I must have downloaded it some years ago from File Exchange. However, IMCLIPBOARD uses Java classes which will no longer be available in R2025a. What can we do?
Thanks
KevinHi everyone,
I really like IMCLIPBOARD. I think I must have downloaded it some years ago from File Exchange. However, IMCLIPBOARD uses Java classes which will no longer be available in R2025a. What can we do?
Thanks
Kevin Hi everyone,
I really like IMCLIPBOARD. I think I must have downloaded it some years ago from File Exchange. However, IMCLIPBOARD uses Java classes which will no longer be available in R2025a. What can we do?
Thanks
Kevin imclipboard MATLAB Answers — New Questions
Import data with filters
% How can I import some data in a table (import with filters)
Name | Age
Hugo|30
Paco|40
Luis |50
Gus|60
% I need import in a table only person with age >= 50% How can I import some data in a table (import with filters)
Name | Age
Hugo|30
Paco|40
Luis |50
Gus|60
% I need import in a table only person with age >= 50 % How can I import some data in a table (import with filters)
Name | Age
Hugo|30
Paco|40
Luis |50
Gus|60
% I need import in a table only person with age >= 50 data import MATLAB Answers — New Questions
Can I run matlab on a removable drive?
When i run the matlab? It indicates error 5201.When i run the matlab? It indicates error 5201. When i run the matlab? It indicates error 5201. removable drive MATLAB Answers — New Questions
How to remove border from MATLAB figure
I’m trying to compare spectrogram images in a MATLAB image analyzer, but I think the white border is causing them to be overly similar. Because of the number of images I need to process, I’d really like to have it automatically generate and save the image. Here is my current code that I’m using to make and save the spectrogram.
base=filename %The code saves multiple images with the label being the filename and a specific addition to each image
figure(1003)
spectrogram(Xacc,windowx,noverlap,nfft,fs,’yaxis’)
ylim([0 5])
colormap(gray(256));
caxis([-160 40])
% title(‘Spectrogram of X’)
s1=base + "SPEC_Acc_X GS";
saveas(gcf,s1,’jpg’)
When I run it I get an image like this.
What I want is an image like this, but in order to get it I had to adjust every setting manually in the image editor. Alternately, is there a way to automatically crop saved images? That could also be a solution.
Thanks so much for the help!I’m trying to compare spectrogram images in a MATLAB image analyzer, but I think the white border is causing them to be overly similar. Because of the number of images I need to process, I’d really like to have it automatically generate and save the image. Here is my current code that I’m using to make and save the spectrogram.
base=filename %The code saves multiple images with the label being the filename and a specific addition to each image
figure(1003)
spectrogram(Xacc,windowx,noverlap,nfft,fs,’yaxis’)
ylim([0 5])
colormap(gray(256));
caxis([-160 40])
% title(‘Spectrogram of X’)
s1=base + "SPEC_Acc_X GS";
saveas(gcf,s1,’jpg’)
When I run it I get an image like this.
What I want is an image like this, but in order to get it I had to adjust every setting manually in the image editor. Alternately, is there a way to automatically crop saved images? That could also be a solution.
Thanks so much for the help! I’m trying to compare spectrogram images in a MATLAB image analyzer, but I think the white border is causing them to be overly similar. Because of the number of images I need to process, I’d really like to have it automatically generate and save the image. Here is my current code that I’m using to make and save the spectrogram.
base=filename %The code saves multiple images with the label being the filename and a specific addition to each image
figure(1003)
spectrogram(Xacc,windowx,noverlap,nfft,fs,’yaxis’)
ylim([0 5])
colormap(gray(256));
caxis([-160 40])
% title(‘Spectrogram of X’)
s1=base + "SPEC_Acc_X GS";
saveas(gcf,s1,’jpg’)
When I run it I get an image like this.
What I want is an image like this, but in order to get it I had to adjust every setting manually in the image editor. Alternately, is there a way to automatically crop saved images? That could also be a solution.
Thanks so much for the help! image editing, border removal MATLAB Answers — New Questions