Extract a row of multiple files in loop

1 visualización (últimos 30 días)
FAISAL
FAISAL el 2 de Jun. de 2014
Editada: Mahdi el 2 de Jun. de 2014
Hi, I would like to get a fixed row from my matrices and save it to one .mat file. for example, in this code, i have 10 different matrices, and would like to save a fixed row (at row 460)from column 1-688. and from the below code, when i put
'line(i) =line+Signal(pixel_line,:);',
it keeps saying
'In an assignment A(I) = B, the number of elements in B and I must be the same.
Error in signal_fluctuation (line 36) line(i) =line+Signal(pixel_line,:);'
please help me. i have no idea how can i do this. BElow is the full code.
clear all close all
addpath 'C:\Program Files\MATLAB\R2012b\toolbox\readimx';
n_i =10; %Number of files
pixel_line = 460;
pixel_line2 = 462;%Pixel line to extract from bottom
Aver_Ray=zeros(520,688);
line=zeros(1,688);
line2=zeros(1,688);
B = readimx('2905_WI-DC\B00001_avg.IM7');
IB = (B.Data);
C = readimx('2905_He-DC\B00001_avg.IM7');
IC = (C.Data);
A = readimx('2905_WI-DC_\B00005.IM7');
IA= single(A.Data);
for i=1:n_i
%Reading file
file_name = '2905_WI-DC_\';
file_end = B00001(i);
A=readimx(strcat(file_name,file_end,'.IM7'));
IA= single(A.Data);
Signal=(IB-IC)'./(IA-IC)';
Fluctuation=std2(Signal);
result(i)=Fluctuation;
line(i) =line+Signal(pixel_line,:);
end

Respuesta aceptada

Mahdi
Mahdi el 2 de Jun. de 2014
I didn't look through the whole code, but based on the error, try the following:
line(i) =line(i)+Signal(pixel_line,:);
Basically, you've defined line (the first time) as a matrix (vector) with 688 values, but when you're telling it to line(i), you're telling the code to only fill one cell, but the right of the equal sign, line is defined as more than one value. I'm not sure what the definition of some of your variables (Signal, Fluctuation, etc...) and their size.
  3 comentarios
Mahdi
Mahdi el 2 de Jun. de 2014
What was the error that you got?
Mahdi
Mahdi el 2 de Jun. de 2014
Editada: Mahdi el 2 de Jun. de 2014
Sorry, I also forgot that you need to use do this:
line(i,:)=line(i,:)+Signal(pixel_line,:);
Also, why are you adding line(i,:) to signal if it's just a row of zeros? Can't you just do this?
line(i,:)=Signal(pixel_line,:);

Iniciar sesión para comentar.

Más respuestas (0)

Community Treasure Hunt

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

Start Hunting!

Translated by