trim a plot and modify mesh

조회 수: 11 (최근 30일)
Federico Paolucci
Federico Paolucci 2022년 12월 12일
편집: Abhinaya Kennedy 2024년 8월 22일
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