Calculation of two less than equal

2 次查看(过去 30 天)
Hi
C = 139*1 double
I want to calculate :

回答(2 个)

John D'Errico
John D'Errico 2020-11-28
编辑:John D'Errico 2020-11-28
You want to solve for a scalar m such that the inequalities are always true? Regardless, does a solution ever exist? Note that unless C > 1, sqrt(C-1) is not real.
fplot(@(C) sqrt(C-1),[1,10])
hold on
fplot(@(C) (1 + sqrt(2*C-1))/2,[1,10])
legend('sqrt(C-1)','1 + sqrt(2*C-1))/2')
You should see that m exists only of C is at least 5. But as long as C is greater than 5, an interval of solutions will exist, for EACH calue of C. We can find the point where the two curves cross.
syms C
solve((1 + sqrt(2*C-1))/2 == sqrt(C-1))
ans =
5
So NO element of C may be less than 5. If that ever happens, then m will not exist. Whem C == 5, M can have only a unique value, thus 2, so the interval collapses to a point.
If you want to solve for a scalar m such that this is ALWAYS true for all values of C, then it is equally trivial, although a solution may likely not exist, For example, consider a vector C that lies between 10 amd 20.
C = rand(1,10)*10 + 10;
m_min = (1 + sqrt(max(C )*2 -1))/2
m_min =
3.60428787739482
m_max = sqrt(min(C ) - 1)
m_max =
3.07214383883712
So we must have m >= 3.6, but also we need m <= 3.07. Clearly no solution exists. We can do further computations to show what range C can have such that a solution can exist.

Setsuna Yuuki.
Setsuna Yuuki. 2020-11-28
For the left side it is:
n = sqrt(C-1);
The other side it is the same.
  4 个评论
Pradip Nath
Pradip Nath 2020-11-28
Hi
I write this code but its seems the for loop only giving equal output not greater than equal value. Also in for loop I can't assign >=
IQ = [1;2;3];
C = sqrt(IQ);
%((1+sqrt(2.*C-1))/2) <= m <= sqrt(C-1)
for m=((1+sqrt(2.*C-1))/2)
while m >((1+sqrt(2.*C-1))/2)
end
disp('m')
disp (m)
end
for m1 = sqrt(C-1)
while m1 < sqrt(C-1)
end
disp('m1')
disp(m1)
end
John D'Errico
John D'Errico 2020-11-28
编辑:John D'Errico 2020-11-28
READ MY ANSWER. In there, I show that if ANY element of C is less than 5, NO solution can exist.
Anyway, you cannot assign an interval to a number, and you cannot do an assignment using an inequality. So it is not at all clear what you wnt to do.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

产品


版本

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by