trim a plot and modify mesh

12 次查看(过去 30 天)
Federico Paolucci
Federico Paolucci 2022-12-12
hi, I would like some advice on how to do this job: I have the plot obtained in matlab available. this plot presents several frames, one after the other, like film. each frame has dimensions of 0.025x0.1.
I have to do two things:
  • cut each frame separating it from the others
  • and then I have to convert the above dimensions to 0.1x0.1. for this activity I thought of using the griddata function, which allows me to switch from initial to final coordinates.
Thanks in advance for the advice

回答(1 个)

Abhinaya Kennedy
Abhinaya Kennedy 2024-8-22
编辑:Abhinaya Kennedy 2024-8-22
Step 1: Extract Frames
Assuming img is your data matrix and you know the dimensions and positions of each frame:
% Define frame dimensions and number of frames
frameHeight = 0.025; % Original height
frameWidth = 0.1; % Original width
numFrames = 10; % Example number of frames
% Preallocate cell array for frames
frameData = cell(1, numFrames);
% Extract each frame
for i = 1:numFrames
% Calculate indices for each frame (replace with actual logic)
rowStart = ...; % Define based on frame position
rowEnd = rowStart + frameHeight - 1;
colStart = ...;
colEnd = colStart + frameWidth - 1;
% Extract the frame
frameData{i} = img(rowStart:rowEnd, colStart:colEnd);
end
This will adjust rowStart, rowEnd, colStart, and colEnd based on the actual positions of your frames within the data.
Step 2: Resize Frames
Using imresize (https://www.mathworks.com/help/matlab/ref/imresize.html) for simplicity, especially if working with image data:
% Define new dimensions
newHeight = 0.1; % New height
newWidth = 0.1; % New width
% Resize each frame
resizedFrames = cell(1, numFrames);
for i = 1:numFrames
resizedFrames{i} = imresize(frameData{i}, [newHeight, newWidth]);
end

类别

Help CenterFile Exchange 中查找有关 Install Products 的更多信息

产品


版本

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by