Problem 23. Finding Perfect Squares
Another of the classic "check if MATLAB has a function that does this already" problems...
What about a vector like [2 3 1]? The top solution will still return true because 1^2 is still one but it is not the square of one of the OTHER numbers.
is the Str2func construct really more effective???
Is it possible that this distorts the metric a bit?
It is currently impossible to submit a solution for this problem. The web page will never load.
The problem description states that one of the numbers has to be a square of one of the OTHER numbers. Still, the test suite tests if  gives true. I think  should give false, or that describtion be modified.
Agree with Mattias. the length of input vector should be 2 or larger.
The difference between test 4 and 5 which returns different answers is the number 36.. but 36 is not a square root of any number of the list in test 4!!
Agree with Mattias: the Test Suite is defective, and not consistent with the problem specification.
Having an input of  is OK, but result should be false, as there is no OTHER element to compare the 1 to!
the word "other" should be ignored in the description...
The heading reads:
"...a square of one of the OTHER numbers...".
How can the function be expected to return [true] for a = ?
It makes no sense.
This problem is very good
空的 1×0 double 行向量
Tough one, but interesting
I solved it with 2 for-loops, 1 function, 1 if-condition.
It works, but there are more efficient ways apparently
Hey,the demand of this problem declare that "if one " and "the other",so if the intersect of x and x.^2 only have one value of 0 or 1,it may be return false because their squares are themselves, which is not satisfy the condition implied that c and c^2 is not one.
The question asks if one number is the square of one of the OTHER numbers. Test 3 should return false.
error in test 7 ! You missed 'd' in function.
Error has been fixed.
Good beginners' question!
So far it is the most time consuming problem for me.
function b = issqr(a);
x = a.^2;
issqr = x;
c = ismember(a,x);
if any(c) == 1
Not sure why this isnt working any help would be appreciated
@Max Weinburg, you have to output logical values not string/char
Great problem for introducing to MATLAB
Solution CommentsShow comments
Problem Recent Solvers15724
Determine whether a vector is monotonically increasing
find the surface area of a cube
More from this Author96
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!