It gives an "Subscripted assignment dimension mismatch" error in the for loop(the bolded line).I tried rechecking all the dimensions.But it wouldnt work and it still gave me an error?

1 view (last 30 days)
I have also attached the mat file in case if something isn't clear. The code that has been mentioned below is incomplete. I left out 3 for loops. At every for loop it shows me the same error. It is not even reaching the 2nd loop as the 1st loop is already erroneous somewhere. I would appreciate any information you could give me. Thank you
This is my code:
frequency=3e9;
propagationSpeed = physconst('lightspeed');
hele = phased.CosineAntennaElement('CosinePower',[2 2]);
N = 128;
k=4;
hsubarray = phased.URA(N/k,'ElementSpacing',[0.05 0.05],'Size',[4 8],'Element',hele);
h = phased.ReplicatedSubarray('Subarray',hsubarray,...
'GridSize',[2 2],'Layout','Rectangular','SubarraySteering','Phase');%in total 128 elements
%viewArray(h,'ShowIndex','All');
steeringAngle1 = [0;60];%azimuth and elevation angles
steerAng1=[120;40];%subarray steering angle
elementVector1 = phased.SteeringVector('SensorArray',h, ...
'PropagationSpeed', 300000000,...
'IncludeElementResponse',true);
h.SubarraySteering='Phase';
w=zeros(128,1);
for m1=1:32
w(m1,1)=step(elementVector1,frequency(m1),steeringAngle1,steerAng1); %this line is the problem
end

Answers (1)

Walter Roberson
Walter Roberson on 23 Aug 2015
Your phased.URA calls for a 4 x 8 array. You asked for the steering vector to include element responses. Therefore your output is going to be at least 4 x 8, one response for each element. You are trying to store that into a single numeric array element.
  3 Comments
Walter Roberson
Walter Roberson on 24 Aug 2015
When you have a 2 x 2 array size, your steering vector will be 2 x 2 . You are trying to store that 2 x 2 result into a single location.
For the moment change your code to
w = repmat({0}, 128, 1);
for m1=1:32
w{m1} = step(elementVector1, frequency(m1), steeringAngle1, steerAng1);
end
Now look at size( w{1} )
rahul allam
rahul allam on 25 Aug 2015
Hey.I did what you suggested.Now it shows "index exceeds matrix dimensions".I understood what you said regarding size.For my code to work i will have to store my [4,8] response of each element into the corresponding destination array each of [4,8] size.My question is "How do i make my destination array [4,8]?"As of now its [4,1].I couldnt figure out the reason as to why it took [4,1].

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!