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 Center および File ExchangeInstall Products についてさらに検索

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by