Index into array out of range error in simulink
3 ビュー (過去 30 日間)
古いコメントを表示
Runtime error: Index into array out of range
Model Name: simm_1
Block Name: simm_1/MATLAB Function
Attempted to access 2 element of data a. The valid index range is 1 to 1
Please note that the simulation will be aborted immediately after you continue from this breakpoint to avoid segmentation violations.
I am a beginner in simulink.Please help me to fix this error . I have attached my simulink model and matlab function
function p1=simm(p)
cp=1;
cp1=5;
a=0.3;
a1=0.4;
b=0.2;
b1=0.4;
for i=1:50
a(i+1)= cp*sin(pi*a1(i))*sin(cp1/a(i));
a1(i+1)= cp*sin(pi*a(i+1))*sin(cp1/a1(i));
end
for i=1:128
a(i+1)= cp*sin(pi*a1(i))*sin(cp1/a(i));
a1(i+1)= cp*sin(pi*a(i+1))*sin(cp1/a1(i));
end
a=a(2:129);
a1=a1(2:129);
for i=1:50
b(i+1)= cp*sin(pi*b1(i))*sin(cp1/b(i));
b1(i+1)= cp*sin(pi*b(i+1))*sin(cp1/b1(i));
end
for i=1:128
b(i+1)= cp*sin(pi*b1(i))*sin(cp1/b(i));
b1(i+1)= cp*sin(pi*b(i+1))*sin(cp1/b1(i));
end
b=b(2:129);
b1=b1(2:129);
N=128;
R=N-1;
for i=1:128
k1=uint8(mod(floor(a*power(10,5)),255)+1);
k2=mod(floor(a1*power(10,5)),R)+1;
p(i,:)=bitxor(p(i,:),k1);
p(i,:)=circshift(p(i,:),[0 k2(i)]);
end
N=128;
R=N-1;
for i=1:128
k1=uint8(mod(floor(a*power(10,5)),255)+1);
k2=mod(floor(a1*power(10,5)),R)+1;
p(:,i)=bitxor(p(:,i),k1');
p(:,i)=circshift(p(:,i),[-k2(i) 0]);
end
N=128;
R=N-1;
for i=1:128
k1=uint8(mod(floor(b*power(10,5)),255)+1);
k2=mod(floor(b1*power(10,5)),R)+1;
p(i,:)=bitxor(p(i,:),k1);
p(i,:)=circshift(p(i,:),[0 k2(i)]);
end
N=128;
R=N-1;
for i=1:128
k1=uint8(mod(floor(b*power(10,5)),255)+1);
k2=mod(floor(b1*power(10,5)),R)+1;
p(:,i)=bitxor(p(:,i),k1');
p(:,i)=circshift(p(:,i),[-k2(i) 0]);
end
p1=p;
end
0 件のコメント
回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Simulink Functions についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!