Subscripted assignment dimension mismatch (size [1 x 1] ~= size [1 x :?])

Hi, I wanted to be:
arr(2,1) = arr(2,1) + abs(5.0 minus 5.1);% where I(1,a) is 5.0 and I(1,a+1)is 5.1
Why couldn't I add the below two together? I got this error message: Subscripted assignment dimension mismatch (size [1 x 1] ~= size [1 x :?]).
Function 'MATLAB Function' (#620.435.485), line 23, column 2:
"arr(count,1) = arr(count,1) + abs(I(1,a)-I(1,a+1))"
Launch diagnostic report.
'I' is declared in worskspace as:
I =[5.0000 5.1000 5.2000 5.2000
90.0000 85.0000 80.0000 20.0000]
integ_signal=zeros(5,4);
a=zeros(10);
arr=zeros(5,4);
count=2;
a=1;
arr(count,1) = arr(count,1) + abs(I(1,a)-I(1,a+1));

7 Kommentare

What is the problem? your code works
Dear Sir, thanks for your reply,
I got this error message: Subscripted assignment dimension mismatch (size [1 x 1] ~= size [1 x :?]).
Function 'MATLAB Function' (#620.435.485), line 23, column 2:
"arr(count,1) = arr(count,1) + abs(I(1,a)-I(1,a+1))" Launch diagnostic report. Do you mean there is nothing wrong to add these two? arr(count,1) = arr(count,1) + abs(I(1,a)-I(1,a+1));
Post the entire code
The complete code is here: and the system:http://imgur.com/poQw0wb
function integ_signal= fcn(I,V,count,oldval)
integ_signal=zeros(5,1);
a=zeros(10);
arr=zeros(2,4);
%b=zeros(10);
integ_signal=oldval;
coder.extrinsic('load');
load('data.mat','I');
a=1;
%b=1;
if count==1
integ_signal(count,1) = 10; % Initial Condition
end
if count>1
%integ_signal(count,1)= integ_signal(count-1,1);
integ_signal(count,1)= integ_signal(count-1,1);
arr(count,1) = integ_signal(count,1);
arr(count,1) = arr(count,1) + abs(I(1,a)-I(1,a+1));
% test_signal=integ_signal
end
a=a+1;
% b++;
end
We can't test your code
May I know what do you mean? I just don't understand why it runs perfectly if I put it in Matlab workspace, however, when it is in Matlab Function Block, i got the above error.
We can't test your code, because we need to load your data, and we have to do it with Simulink model

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Gefragt:

am 7 Nov. 2013

Kommentiert:

am 7 Nov. 2013

Community Treasure Hunt

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

Start Hunting!

Translated by