フィルターのクリア

error with 20x10 array in a function

1 回表示 (過去 30 日間)
ETSII Departamento de Ingenieria Electrica
回答済み: Rizwana 2014 年 2 月 14 日
Hi;
Im having this error when i run "fcp" function (detailed below).
??? Attempted to access ASEB(1,1); index out of bounds because size(ASEB)=[0,0].
Error in ==> fcp at 15
Vsal(x)=ASEB(i,j);
Working out of the function, all variables load but it seems ASEB is not operating in the function.
Hope someone can help me
function [ Cp ] = fcp( beta,lambda )
%FCP Summary of this function goes here
% Detailed explanation goes here
global ASE
%ASE matrix loaded in workspace previously
ASEB=(0.0003*beta.^3 -0.0044*beta.^2 -0.0479*beta + 1.0850)*ASE;
x=0;
for i=1:20;
for j=1:10;
x=x+1;
Vsal(x)=ASEB(i,j);
end;
end;
%como el vector Vsal tambien se reduce en abcisas, habra que multiplicarlo
%de nuevo por otra funcion de B
fB2=(0.0026*beta.^2 -0.1031*beta + 1.2393);
Vsal=fB2*Vsal;
i=(200/20)*lambda;
fix(i);
Cp=Vsal(i);
end
  1 件のコメント
Wayne King
Wayne King 2014 年 2 月 13 日
Please format your code and you need to tell us the size of beta and lambda, give us some representative values.

サインインしてコメントする。

採用された回答

Rizwana
Rizwana 2014 年 2 月 14 日
Your ASE is matrix of what size?? Must be huge.. try to loop it...
r = size (ASE);
for i = 1:r(1) % 1:r(2) assuming it is column-vector.
values = Asme(:,1); %reads all values
ASEB=(0.0003*beta.^3 -0.0044*beta.^2 -0.0479*beta + 1.0850)* values;
output(i,:) = ASeb;
end
outputfilename = ['output\' outputfilename];
dlmwrite(outputfilename,output, '\t');
% now use this aseb for further calculations... I hope i got this question right. Since you are not looping over your values, it is storing only last set of data

その他の回答 (1 件)

Andrei Bobrov
Andrei Bobrov 2014 年 2 月 13 日
編集済み: Andrei Bobrov 2014 年 2 月 14 日
function Cp = fcp( beta,lambda )
global ASE
Vsal = polyval(conv([0.0003,-0.0044,-0.0479,1.085],...
[0.0026,-0.1031,1.2393]), beta)*reshape(ASE',[],1);
Cp = [];
try
Cp = Vsal(fix(10*lambda));
catch
disp('Look size of ASE and value of lamda');
end
end

カテゴリ

Help Center および File ExchangeMathematics についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by