What does a=[b(90:end) b(1:89)] represent ?
Afficher commentaires plus anciens
See code section below:
temp1= hor(tilt(t), h, d1, d2,col5, a_z); %call function
temp2=[temp1(90:end) temp1(1:89)];
hor_Mxt(t,r,col5).alphaS = temp1;
hor_Mxt(t,r,col5).alphaE = temp2;
function alpha=hor(~, h, d1, d2, col5, a_z)
alpha=rad2deg(atan(cosd(a_z)*h/d1));
alpha(alpha<0)=0;
az_frame=rad2deg(atan(col5/d2));
alpha(a_z>az_frame)=0;
end
I do not understand what is the relation between temp1 and temp2. What is temp1 storning and what is temp2 storing?
Réponse acceptée
Plus de réponses (1)
John D'Errico
le 12 Août 2021
Modifié(e) : John D'Errico
le 12 Août 2021
You very clearly need to spend some time with a MATLAB manual or tutorial. You are asking a basic question, that would be covered at the very beginning of any such document.
What does temp1(90) do? Answer: it extracts element 90 of the vector.
What would temp1(91) do? Answer: it extracts element 91 of the vector. Etc.
What would temp1(90:93) do? Answer: It extracts elements [90 91 92 93] from the vector.
What would temp1(90:end) do? Answer: It extracts all the elements from #90 to the very end of the vector.
For example...
temp1 = primes(20)
temp1(5:end)
So it extracted the 5th element, up to the very last element.
Similarlly,
temp1(1:4)
So the first 4 elements of the vector.
Now, how can we combine parts of vectors into a new vector? We use the square brackets, thus [].
temp2 = [temp1(5:end) ,temp1(1:4)]
Now go back and look at your question. How did this rearrange the elements of our example vector? What would it do in your problem?
And then go back and read the help documents for MATLAB. I suggest the MATLAB Onramp tutorials. But you can also find guided tutorials on YouTube.
1 commentaire
Hannah
le 12 Août 2021
Catégories
En savoir plus sur Cell Arrays dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!