# How to get all positive values of 'm' from the given domain of two variables?

1 view (last 30 days)
Atique Khan on 30 Oct 2018
Answered: Abhishek Kumar on 9 Jul 2019
I have an equation in two variables naming a and b with domains 0.5 to 1 with step size equal to 0.01 for both a and b. I want to have all values of a and b on which the m results a positive number. The equation is given as and denominator is given separately. I make use of for loop to do so but it didnt work and I am new around with MATLAB to know the exactly how can I do this to be done.
m(a,b)= (4*(a^2 + b^2)^(3/2)*(-8*a^3 + 8*a^3*b^3 +sqrt(a^2 + b^2)*(a^2 + 7*a^5 + b^2 + 7*a^3*b^2 -8*a^2*b^3 - 8*b^5)))/d
where
d=15 *a^6 + 45* a^4* b^2 + 64* a^3* b^3 + 45* a^2* b^4 + 15* b^6 -64 *sqrt(a^2 + b^2) *(a^5 + a^3* b^2 + a^2* b^3 + b^5)

Abhishek Kumar on 9 Jul 2019
i=1;
j=1;
cans=zeros(1,10);
lans=zeros(1,10);
for a=0.5:0.01:1
for b=0.5:0.01:1
d=15 *a^6 + 45* a^4* b^2 + 64* a^3* b^3 + 45* a^2* b^4 + 15* b^6 -64 *sqrt(a^2 + b^2) *(a^5 + a^3* b^2 + a^2* b^3 + b^5);
m= (4*(a^2 + b^2)^(3/2)*(-8*a^3 + 8*a^3*b^3 +sqrt(a^2 + b^2)*(a^2 + 7*a^5 + b^2 + 7*a^3*b^2 -8*a^2*b^3 - 8*b^5)))/d;
if m>0
cans(i)=a;
lans(i)=b;
i=i+1;
end
end
end
Try this code
works fine for me.
'cans' stores the value of 'a' and 'lans' stores the value of 'b' at the same index.

R2013b

### Community Treasure Hunt

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

Start Hunting!