for loop question

Hello, I tried to 2 read xls files to do some operation which I need in my script, but I get the following errors; ??? In an assignment A(I) = B, the number of elements in B and I must be the same.
Error in ==> get_calib_value7 at 214 NetOD_Redmean(e)= g(:,3)- k(:,3); My script is as the following steps: >g = xlsread('calibb.xls'); >k = xlsread('calibb_BK.xls'); %% % uitable for plotting resultdata >scrsz = get(0,'ScreenSize'); >f = figure('Position',[50 50 scrsz(3)/2 scrsz(4)/4]); >columnname = {'Filename','NetOD_Redmean', 'NetOD_Redmax','NetOD_Bluemean','NetOD_Bluemax', 'SD_Redchannel','SD_Bluechannel','ChannelRatio'}; >columnformat = {'char','numeric', 'numeric', 'numeric','numeric','numeric','numeric','numeric'}; >columneditable = [false false false false false false false false]; >dat = []; >for e =1:9;
>NetOD_Redmean(e)= g(:,3)- k(:,3);
> NetOD_Redmax(e) = g(:,4)- k(:,3);
>dattemp = {char(filename(e)),NetOD_Redmean(e),NetOD_Redmax(e);};
>dat = [dat;dattemp]; %#ok<AGROW>;
> t = uitable('Units','normalized','Position',...
[0.1 0.1 0.9 0.9], 'Data', dat,...
'ColumnName', columnname,...
'ColumnFormat', columnformat,...
'ColumnEditable', columneditable,...
'Parent',f); %#ok<NASGU>
> clear A B AB BV Button Default I J I1 J1 I1a J1a M V Xi Yi BB BV2
>end
I will be pleased if someone can help me with this problem?
Regards

回答(1 个)

When you do things like this:
NetOD_Redmean(e)= g(:,3)- k(:,3);
You must ensure that you have enough "room" inside NetOD_Redmean(e) to hold all elements of the operation g(:,3)- k(:,3)
numel(e)
numel(NetOD_Redmean(e))
numel(g(:,3)- k(:,3))

此问题已关闭。

标签

提问:

Kha
2011-3-11

关闭:

2021-8-20

Community Treasure Hunt

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

Start Hunting!

Translated by