How to product two vector with difference sizes?

조회 수: 2 (최근 30일)
Habib
Habib 2016년 4월 23일
편집: Habib 2016년 4월 24일
Hi,
I need to product two vector as Ta and r1 but I got error (In an assignment A(I) = B, the number of elements in B and I must be the same.). in fact, my goal is make iteration on all body of script. I couldn't understand what is wrong?
my codes is following as:
N=100; a=0; a1=10; a2=5;
alfa=0.5*pi/180;
teta0=ones(1,3); L=ones(1,3); B=L; Ta(:,:)=ones(1,3);
Roc=inf; Rdisk=inf; landa=1.03e-3; k=2*pi/landa;
r1=linspace(a,a1,N); r2=linspace(a,a2,N);
n=[1.45 1.8153 2.4];
for s1=1:size(n)
teta0(s1)=(n(s1)-1)*alfa; L(s1)=0.5*a1./teta0(s1); B(s1)=L(s1);
kernel12=ones(1,N,s1); kernel21=ones(1,N,s1);
H12=ones(1,N,s1); H21=ones(1,N,s1);
Ta(s1)=exp(-1i*2*teta0(s1)*k*r1);
Tdisk=exp(-1i*k*r2.^2/Rdisk);
Ttot=Ta(s1).*Tdisk(1:N);
Toc=exp(-1i*k*r2.^2/Roc);
end

답변 (1개)

Azzi Abdelmalek
Azzi Abdelmalek 2016년 4월 23일
편집: Azzi Abdelmalek 2016년 4월 23일
Line 11 should be
Ta(s1)=exp(-1i*2*teta0(s1)*k*r1(s1));
You missed the index s1 in r1 (r1(s1) insteas of r1)
  댓글 수: 2
Habib
Habib 2016년 4월 23일
thanks,
I think it is couldn't best idea because the size of r1 is 1*200 and when we use r1(s1) instead of r1 only 3 elements of r1 selected because s1 is a 3 elements vector.
it is my idea and I don't know that it is true.
another problem, that I faced it, is kernel12(:,:,1)=0 and kernel12(:,:,2) has value, what is wrong? whereas it must has value.
Azzi Abdelmalek
Azzi Abdelmalek 2016년 4월 23일
This your problem, you should know what are the sizes of your data. What is the expected size of Ta?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Performance and Memory에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by