Never realized that MATLAB sees a defined assignment (y = 2*x) different than no assignment (2*x => assignment to ans).
If anything, I would have guessed the second would be (slightly) more effort.
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
It works, but it's ugly :-)
Nice! :)
Never realized that MATLAB sees a defined assignment (y = 2*x) different than no assignment (2*x => assignment to ans).
If anything, I would have guessed the second would be (slightly) more effort.
does this variable "ans" overrides MATLAB's default "ans"?
ok, i got there in the end. but it defeats the rules - there is no "y" variable when you change the template to ans = times2(x)...
how do you know what the rules are?!?
comment section gives a great info
comments really help! lol
David Amor, the rules specify that you have to assign it to a "y" variable. You just need to do
y = times2(x);
Great!
Hi Dirk, can you pls tell me how you got size 10 ?
To get size 10 you have to change y to ans:
function ans = times2(x)
2*x;
end
Nice solution!
nice solution