Unable to perform assignment because the left and right sides have a different number of elements.

1 vue (au cours des 30 derniers jours)
I am trying to apply a calculation to each element of an array 'v' and store the result of the calculation into an array 'M'. However, I am getting the error in the title. Any help is appriciated.
function M=invPM(nu,gamma)
syms x
eq1= sqrt((gamma+1)/(gamma-1))*atan(sqrt((gamma-1)/(gamma+1)*((x^2-1))))-atan(sqrt(x^2-1))==nu;
M=abs(vpasolve(eq1,x));
end
function [M,mu]=getMachs(v,gamma)
M=zeros(1,length(v));
mu=zeros(1,length(v));
for i=1:length(M)
M(i)=invPM(v(i),gamma); %This line throws the error
mu(i)=MachAngle(M(i));
end
  5 commentaires
Walter Roberson
Walter Roberson le 31 Déc 2019
There are no real-valued solutions for those values. There are no real-valued solutions for any v greater than pi * (sqrt(6)-1)/2 about 2.27685 for that gamma.
My tests suggest that there are no real-valued gamma that can satisify that equation for that value of v.
David Goodmanson
David Goodmanson le 31 Déc 2019
HI Govind,
If x is supposed to be real and the result is real, then since 0 <= atan(..) <=pi/2 (for positive argument),
sqrt(2.4/.4) = 2.45
0 <= [first term] <= 2.45*pi/2;
0 <= [second term] <= pi/2;
and there is no way these terms are going to combine to give 36.7. One way out is to take a different branch of atan, which means you can add m*(pi/2) to one of the atan results, with m an arbitrary integer. If it's justifiable, which seems possible if somewhat unlikely.

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Gamma Functions dans Help Center et File Exchange

Tags

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by