hi, I do not understand why when a submit my code i get an error, it said "check data".
Mohamed, the check plotted data error suggests that the data you are plotting in the plot command does not match the data you are expected to plot i.e. your y and m variables. The red star marker must be on the minimum value of any given input signal y.
I kept getting an error plotting star with both 'p' and 'h', it only accepted the code when I changed it to an asterisk '*'. please modify the question to made it more understandable.
Thanks Ian for pointing out the error. I have updated the description to use the appropriate name for the marker.
Even without plotting the graph ploblem is getting solved and accepted. So, there is no point in comparing our solution witht the leading solution!
Omkar- Thanks for pointing out the issue with the test suite. I have modified messages to errors when the solution has no plot or too many plots. The solutions will be rescored.
I put this code in my desktop Matlab and the plot looks fine, but Cody says it's wrong. Can someone give me a hint?
function plot_cos(y, t)
t = linspace(0,15,400);
[val,i]=min(exp(-0.5*t).*cos(2*pi.*t));
plot(t,(exp(-0.5*t).*cos(2*pi.*t)),'b--',t(i),val,'r*')
end
my solution is accepted but the feedback is broken. I get this message.
"We're sorry, but something went wrong.We've been notified about this issue and we'll take a look at it shortly."
I received the same msg as Jimmy although my code was accepted: "We're sorry, but something went wrong.We've been notified about this issue and we'll take a look at it shortly."
I have tried with below command,but its not working.Kindly suggest some hints.
function m = plot_cos(y, t)
plot(m(min),"r * ") ;
end
you should be really careful about the description of the question, for example, i failed a few times for not notice i should use "m" to denotes the min.
This comment saved me a big headache. No idea what they wanted from m.
The test suite should also verify that the red dot has been placed correctly. In fact, even if the abscissa of the point in question is taken wrong, the wrong code is accepted as a solution.
There is a bug on the verification, the minimum value with the lowest size solution is not plotted at the correct time value.
function m = plot_cos(y, t)
[m,pos] = min(y);
plot(t,y,'b--',t(pos),m,'r*');
function m = plot_cos(y, t)
[m,idx]=min(y);
t_m=t(idx);
plot(y,t,'b--',m,t_m,'r*')
end
why doesn't it work? It gives the error "Check plotted data" but my data works just fine on my pc. Any ideas on why it doesn't accept my solution?
Just change the order in plotting, i.e,
plot(t,y,'b--',t_m,m,'r*')
since plot(x,y) is main function.
x->t and y->y
I have submitted the code which is working exactly as required in matlab script but cody is not accepting my solution.Please help
Why is this program failing?
function m = plot_cos(y, t)
j = size(y);
k = zeros(1,j(2));
a = k - y;
b = max(a);
k = find(a==b);
m = -b;
plot(t,y,'--',t(k),m,'r*');
end
function m = plot_cos(y, t)
plot(t,y,'b--')
[value,index]=min(y)
hold on
plot(t(index),y(index),'r*')
m=value
end
There seems to be a bug in the test suite. This is passed as a valid solution, although the minimum point is not correctly marked.
To give a correct result, line 3 should read:
plot(t,y,'b--',t(im),m,'r*');
absolutely, but the thing is how other peers were able to submit
Undefined function 'minus' for input arguments of type 'matlab.graphics.chart.primitive.Line'.
Error in Test1 (line 5)
assert(abs(m - (-0.781239288889930)) <= 1e-4)
i cant understand this error the code just works fine on matlab
function m = plot_cos(y, t)
[val,i]=min(y);
m=plot(t,y,'b--',t(i),val,'r*');
end
function m = plot_cos(y, t)
[val,i]=min(y);
m=plot(t,y,'b--',t(i),val,'r*');
end
this code works fine on pc but just got error on test
Undefined function 'minus' for input arguments of type 'matlab.graphics.chart.primitive.Line'.
Error in Test1 (line 5)
assert(abs(m - (-0.781239288889930)) );
end
Hi Ali, this is because the output m is expected to contain the minimum value of the input y, not a handle to the plot.
Hope that helps.
function m = plot_cos(y, t)
[m,idx]=min(y);
t_m=t(idx);
plot(t,y,'b--',t_m,m,'r*')
end
:-D
I have the same problem lol, and thanks for pointing out the blind spot!
the test syntax in line 5 is wrong
So we don't need to plot the graph?
That is correct. The problem description is one thing. The test suite is another. The test suite explicitly accommodates solutions that do not plot the graph. Since this took extra effort to incorporate into the test suite, I view my solution as fully within the scope and intent of this problem.
It works perfectly fine on PC.
Thanks Paresh. Your approach is a valid solution that the tests were not designed to evaluate previously. I have now modified the tests to pass this alternative approach. However, there are two other issues with this solution, which you will have to resolve: 1. The color 'b' expected for the line is not the same as the default blue color the MATLAB uses. 2. The output is expected to be the minimum value of y, not a handle to the plot.
I have also added appropriate messages for the tests. Thanks again!
why it is failing..i dont understand..it gives no indication why assertions have failed
Hi Asif, the output from the function is expected to be only the minimum value of vector y; whereas your code returns both - the minimum value of y and also the corresponding t. This is causing the last test to fail. I will modify the tests to make it clearer. You should pass the tests if you set m = ymin
thank u
Hey any chance i could get a little help with 44934 Plot Damped Sinusoid
I don't understand what is wrong. The output below states that the assertion failed on test 2, but it gives no indication of which assertion failed or what the cause was. I plotted this on my matlab and it produced the plot shown in the problem statement. Please clarify what the error is in my code.
Andrew, I suspect that this is failing the second test because the new plot lines are being plotted over the previous plot (from test 1). It is always a good practice to use 'hold off' (here and in MATLAB, generally) to stop plotting over old plots. Having said that, I will consider adding a 'figure' command to the tests, since Cody does not display the plots and it is difficult to debug this particular problem without seeing the plots.
Pooja, you were correct. Adding the hold off command to the end of the code allowed it to submit successfully. Thank you.
1088 Solvers
373 Solvers
Find the maximum number of decimal places in a set of numbers
1094 Solvers
3016 Solvers
Tick. Tock. Tick. Tock. Tick. Tock. Tick. Tock. Tick. Tock.
829 Solvers
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!