Main Content

Results for


In problem 16 I used the following solution:
function b = nearZero(a)
b = max(a(imdilate(a == 0, [1 1 1])));
end
It is working pretty well on mathlab but when I submit my answer to cody, the following error is generated:
Undefined function 'imdilate' for input arguments of type 'double'.
Error in nearZero (line 2)
b = max(a(imdilate(a == 0, [1 1 1])));
Error in Test1 (line 3)
assert(isequal(nearZero(a),b))
In number 5, its written that the correct answer is c = 1 but the secomnd person has more change than the first person, therefor the correct answer should be 2.Likewise in number 6.
Hi, I'm trying to solve this problem but I'm getting an error so far.
Problem:
Given a vector a, find the number(s) that is/are repeated consecutively most often. For example, if you have
a = [1 2 2 2 1 3 2 1 4 5 1]
The answer would be 2, because it shows up three consecutive times
What I've written so far (not done):
a = [1 2 2 2 1 3 2 1 4 5 1];
[x,y] = size(a);
counter = zeros(1,10);
if x == 1
for i=1:1:y
if a(i) == a(i+1)
counter(a(i)) = counter(a(i))+1
end
end
else
for i=1:1:x
if a(i) == a(i+1)
counter(a(i)) = counter(a(i))+1
end
end
end
But it says "error" in the line of "if a(i) == a(i+1)". I noticed that it creates a variable called "i" which value is 11, but it should create a vector from 1 to 11. What's wrong here?
I know my solution might not be in the right direction or something, but please don't tell me anything!
Thanks in advance
This is the 5th installment of the wish-list and bug report thread.
This topic is the follow on to the first Wish-list for MATLAB Answer sections and second MATLAB Answers Wish-list #2 (and bug reports). The third started out as New design of the forum - grey on white and the fourth MATLAB Answers Wish-list #4 (and bug reports) is also growing so large it is slow to load and navigate.
Same idea as the previous ones: one wish (or bug report) per answer, so that people can vote their wishes.
What should you post where?
Wishlist threads (#1 #2 #3 #4 #5 #6): bugs and feature requests for Matlab Answers
Frustation threads (#1 #2): frustations about usage and capabilities of Matlab itself
Missing feature threads (#1 #2): features that you whish Matlab would have had
Next Gen threads (#1): features that would break compatibility with previous versions, but would be nice to have
@anyone posting a new thread when the last one gets too large (about 50 answers seems a reasonable limit per thread), please update this list in all last threads. (if you don't have editing privileges, just post a comment asking someone to do the edit)
Dear Sir or Madam
I tried to solve the cody-problem namend in the title.
Could you pleas tell me how I should name the vektor/variable in which it should be presentet?
Thank you for helping me.
Yours faithfully
Jann Borlinghaus
I wrote a Cody problem, but I want to prevent people from using tricks to get a false "best" solution.
For example, many people do something like the following:
regexp '' '(?@"CODE HERE)';
in order to get the size of their program down to something quite small. I want to prevent this. I have seen people using some weird tests to try to block this, but I don't know how they work and when I try to copy them they fail.
Would it make sense that, in order to enhance coding experience with practice exercises, each section of the Matlab Academy courses reference specific CODY problems related to that section so the CODY problems can be used in parallel with the structure of the Matlab Academy courses?
I started with Cody today and I found the file calculateSize.m https://de.mathworks.com/matlabcentral/fileexchange/34754-calculate-size which should determine the size of my solution. Unfortunately I do not get it to run. Can someone explain this to me or maybe explain how exactly the size of the solution is calculated?
Gregory
Gregory
Last activity on 13 Jun 2017

Something seems to either have changed with webread/urlread behavior with R2016a or the Cody site has changed its authentication after it's September 2016 upgrade. Now, when ever I make a call using either webread (with weboptions) urlread using "My Cody" url, I get the html that corresponds to an unauthenticated user.
I've tried passing credentials using weboption and also cached the credentials using the built in Matlab browser - neither helped in seeing the authenticated version of this page.
Any help in understanding where the problem/solution lies would be helpful. Easily reproduced by running...
URL = 'https://www.mathworks.com/matlabcentral/cody/players/1261697-gregory/solved';
[Contents Status] = urlread(URL);
Compare this to the source pulled down when authenticated with Chrome (for example, search for the work "two"). FYI: this has worked for a couple of years up until now...
Inspired by Chad Greene's " MATLAB jokes or puns " thread, and in celebration of 15 years of the MathWorks Community site, does anyone out there want to share their poetic creativity? Limericks, haiku, sonnets... Go!
And to start off, my (slightly off-topic) submission on Chad's thread:
There was an old math guy called Cleve
who, while teaching, a pipe-dream conceived:
of a language so clean
you can say what you mean!
From our suffering we've all been relieved.
O45
O45
Last activity on 23 Oct 2018

Hi, I am uploading the answers to cody problems. Although most of answers are correct but my size is bigger than the best answer. How can I view the best answer?
Edit: due to the increasing size of this thread, it is continued here.
What should you post where?
Wishlist threads (#1 #2 #3 #4 #5 #6): bugs and feature requests for Matlab Answers
Frustation threads (#1 #2): frustations about usage and capabilities of Matlab itself
Missing feature threads (#1 #2): features that you whish Matlab would have had
Next Gen threads (#1): features that would break compatibility with previous versions, but would be nice to have
@anyone posting a new thread when the last one gets too large (about 50 answers seems a reasonable limit per thread), please update this list in all last threads. (if you don't have editing privileges, just post a comment asking someone to do the edit)
This topic is for features you would like to see for the MATLAB Answers facility itself, and also for bug reports about the MATLAB Answers facility.
This topic is the follow on to the first Wish-list for MATLAB Answer sections and second MATLAB Answers Wish-list #2 (and bug reports). Those grew large enough to become unwieldy; and Mathworks has made enough changes to make a number of the past points no longer of relevance. More recently there was the limited purpose New design of the forum - grey on white which turned into a bug and wish list; I have renamed that for continuity.
I suggest one wish (or bug report) per answer, so that people can vote their wishes.
James
James
Last activity on 11 Jun 2015

Apologies for putting this question here, but I'm not sure there's a specific forum for Cody-related questions.

I recently noticed that a new badge for "Magic Numbers Master" had been created and awarded. When I entered my profile to check that out, I noticed that I had received that badge, but lost the badge for "Cody Challenge Master." I thought that maybe my solution had been messed up because of a change in one of the test suites that my solution missed, as this has happened a number of times on other problems. According to the text underneath the badge icon, I've still solved all 96 of the questions in the Cody Challenge. All of the problems listed as part of that challenge are still marked as "Solved." Has anyone else run into this issue?

Chad Greene
Chad Greene
Last activity on 12 Sep 2023

Are there any good Matlab jokes? I don't mean why or any other Easter eggs, I mean good jokes involving Matlab. Actually, that bar may be a bit too high. Any jokes, good or bad, let's hear 'em.
NOTE: this discussion is continued at MATLAB Answers Wish-list #6 (and bug reports)
I've opened MATLAB Answers this morning and found the new design.
The field for typing the "Body" does not consider the font settings of my browser anymore, such that my preference of sans-serif fonts is ignored. In addition the text color is a medium gray, which is hard to read for me due to the too light contrast.
Blank lines in the code let two separate code boxes appear. This makes almost all code, I've posted in the forum, invalid. It has been discussed repeatedly, that blank lines in the code confuse the indentation of the display in the forum and that this is a really bad idea. But instead of improving this, it is made severely worse now.
The new design contains even more white space, such that standard questions cannot be answered without extensive vertical scrolling. It is a very bad drawback, that I cannot see the question while I type the answer.
There is still no suggestion to use a proper code formatting, such that I have to spend 20% of my forum time typing corresponding comments as before.
But I'm coming back to the most important problem for me: It is a physical problem for me to read the low contrast grey on white text. Does anybody know a tweak or CSS trick to increase the readability?
TMW, please take into account that this new design is physically hard to read for people without young and 100% perfect eyes. This is very annoying for me.
Splitting code blocks at white lines is simply a bug. I cannot imagine why this error has not been detected before the new design has been published. The argument, that TMW is extremely conservative with changes in the forum to ensure a stability does not convince me anymore.
[EDITED] The box around the thread, the preview box, the boxes for preformatted text and code have a grey background now. So some text is even medium grey on light grey.
I'd be glad if the designers refocus on the purpose of the forum. Whatever this purpose might be, the optical reception of the characters is fundamental.
I created a solution for Cody Problem 1745 (Get me!) that is very simple and works perfectly on my computer; but in Cody, it results in the error:
Error: Undefined function or variable 'me'.
The test code is:
get = me();
y = rand(1,12345);
!rm now.m
!rm assert.m
assert(get == now)
My solution is:
classdef me
methods
function tf = eq(obj,~)
tf = true;
end
end
end
Why doesn't Cody accept this?
(P. S.) And why doesn't it accept function definitions like
function justDoIt
(which are appropriate for some problems and accepted by MATLAB) but requires at least one input and output?
Can anyone explain how Cody calculates the size of a program?
I read the help, but couldn't understand. :(
Why cody does not allow 'eval', 'evalc','feval' etc functions in the solutions? What is alternative to these functions?
e.g. I need to use:
if f='3*x'
x=0:10;
y=eval(vectorise(f))
so that values of y can be calculated as 3.*x
bt cody does not let us to use functions like eval
What is the alternative?