Info

This question is closed. Reopen it to edit or answer.

help with this basic matlab code..

2 views (last 30 days)
YJ
YJ on 8 Oct 2014
Closed: MATLAB Answer Bot on 20 Aug 2021
Here is a code I wrote,
I want the each file to be cut off
I got right up to cut_2 bit.
But problem comes in Mean_process_cut_cut_image_posi = rot90(cut_2,3);
I want to rotatte the image and want to call it as Mean_process_cut_cut_image_posi
But when I run, in a workspace it only shows
Mean_process_image_pos1
....
Mean_process_image_pos5
and
Mean_process_cut_cut_image_posi
whereas I want to have
Mean_process_cut_cut_image_pos1
Mean_process_cut_cut_image_pos2
Mean_process_cut_cut_image_pos3
I think this should be easy bit... but I am stuck at this for an hour..
Here is my code.
files = dir('*.mat');
for i=1:5
load((['Mean_process_image_pos',num2str(i),'.mat']));
%load(files(i).name);
cut_1 = rot90(Mean_process_image_pos1, 3);
x = 193; %10mm
y = 768 -x;
cut_2 = cut_1(:,x:y);
Mean_process_cut_cut_image_posi = rot90(cut_2,3);
end
stacked_cut_image= [ Mean_process_cut_cut_image_pos5;Mean_process_cut_image_pos4;Mean_process_cut_image_pos3;Mean_process_cut_image_pos2;Mean_process_cut_image_pos1];

Answers (1)

Iain
Iain on 8 Oct 2014
The answer you're looking for is actually really really really horrible:
Mean_process_cut_cut_image_posi = rot90(cut_2,3);
Should be:
eval(['Mean_process_cut_cut_image_pos' num2str(i) ' = rot90(cut_2,3);']);
But that is awful matlab. You should replace it with:
stacked_cut_image(i,:) = rot90(cut_2,3);
  1 Comment
YJ
YJ on 8 Oct 2014
When I sub
stacked_cut_image(i,:) = rot90(cut_2,3);
instead of
Mean_process_cut_cut_image_posi = rot90(cut_2,3);
I got an error message..

Community Treasure Hunt

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

Start Hunting!