主要内容
Results for
I love the smell of debugged MATLAB code in the morning. Smells like...Victory!
Halloween Analysis of Many Aspects of Halloween Headquarters and Effects on USA
(Note to Chistopher: I used a simple ESP8266 generating random numbers for fields 1 thru 7, (0 to 100, 4000, 127, 30, 45, 200,000, 50,000) and 0 to 1 for field 8. And a couple of real sensor inputs.
I'm in a community conference in Boston today and see what snacks we get! The organizer said it's a coincidence, but it's definitly a good idea to have them in our MathWorks community meetings.
(Sorry - it should be 2023b by now.)
spy
Calling all students! New to MATLAB or need helpful resources? Check out our MATLAB GitHub for Students repository! Find MATLAB examples, videos, cheat sheets, and more!
Visit the repository here: MATLAB GitHub for Students
Imagine x is a large vector and you want the smallest 10 elements. How might you do it?
To solve the puzzle, first unscramble each of the words on the left. Then rearrange the letters in the yellow shaded boxes to complete the sentence on the right.
If you enjoyed this puzzle let me know with a like or in the comments below and I'll post more of them. Please don't post your answer, or any hints, and spoil it for those who come across this puzzle after you!! If you want to check your answer, you can messge me your guess through the link on my profile card (click on my name, Rena Berman, above and then on the envelope icon in the top right corner of the profile card that appears).
Thats the task:
Given a square cell array:
x = {'01', '56'; '234', '789'};
return a single character array:
y = '0123456789'
I wrote a code that passes Test 1 and 2 and one that passes Test 3 but I'm searching a condition so that the code for Test 3 runs when the cell array only contains letters and the one for Test 1 and 2 in every other case. Can somebody help me?
This is my code:
y = []
[a,b]=size(x)
%%TEST 3
delimiter=zeros(1,a)
delimiter(end)=1
delimiter=repmat(delimiter,1,b)
delimiter(end)=''
delimiter=string(delimiter)
y=[]
for i=1:a*b
y = string([y x(i)])
end
y=join(y,delimiter)
y=erase(y,'0')
y=regexprep(y,'1',' ')
%%TEST 1+2
for i=1:a*b
y = string([y x(i)])
y=join(y)
end
y=erase(y,' ' )
That's the question: Given four different positive numbers, a, b, c and d, provided in increasing order: a < b < c < d, find if any three of them comprise sides of a right-angled triangle. Return true if they do, otherwise return false .
I wrote this code but it doesn't pass test 7. I don't really understand why it isn't working. Can somebody help me?
function flag = isTherePythagoreanTriple(a, b, c, d)
a2=a^2
b2=b^2
c2=c^2
d2=d^2
format shortG
if a2+b2==c2
flag=true
else if a2+b2==d2
flag=true
else if a2+c2==d2
flag=true
else if c2+b2==d2
flag=true
else flag=false
end
end
end
end
end
That's the question:
The file cars.mat contains a table named cars with variables Model, MPG, Horsepower, Weight, and Acceleration for several classic cars.
Load the MAT-file. Given an integer N, calculate the output variable mpg.
Output mpg should contain the MPG of the top N lightest cars (by Weight) in a column vector.
I wrote this code and the resulting column vector has the right values but it doesn't pass the tests. What's wrong?
function mpg = sort_cars(N)
load cars.mat
sorted=sortrows(cars,4)
mpg = sorted(1:N,2)
end
I recently have found that I am no longer able to give my difficulty rating for questions on Cody after sucessfully completing a question. This is obviously not a big deal, I was just wondering if this was an issue on my end or if there was some change that I was not aware of.
The option to rate does not pop up after solving a problem, and the rating in general does not even show up anymore when answering questions (though it is visible from problem groups).
When solving problems over on Cody, I can almost always view all solutions to a problem after submitting a correct solution of my own. Very rarely, however, this is not the case, and I instead get the following message:
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.
You may solve another problem from Community group to unlock all the solutions to this problem.
If this happens, then again, I can almost always rectify this by submitting a (correct) solution to a different problem (I take it that the Community group is the implicit group of all problems on Cody --- is it?). But sometimes that, too, fails.
So my question is, why? What are the criteria that determine when all solutions are, in fact, unlocked?
Simple question: I noticed there's a Modeling & Simulation Challenge Master badge over on Cody, but I can't find the corresponding group. So: where is it? Does it still exist at all?
Error: The server timed out while running and assessing your solution in MATLAB CODY. How do I resolve this? My code is correct. I have run it on PC. But, when i submit in CODY the server throws an error.
I've now seen linear programming questions pop up on Answers recently, with some common failure modes for linprog that people seem not to understand.
One basic failure mode is an infeasible problem. What does this mean, and can it be resolved?
The most common failure mode seems to be a unbounded problem. What does this mean? How can it be avoided/solved/fixed? Is there some direction I can move where the objective obviously grows without bounds towards +/- inf?
Finally, I also see questions where someone wants the tool to produce all possible solutions.
A truly good exposition about linear programming would probably result in a complete course on the subject, and Aswers is limited in how much I can write (plus I'll only have a finite amount of energy to keep writing.) I'll try to answer each sub-question as separate answers, but if someone else would like to offer their own take, feel free to do so as an answer, since it has been many years for me since I learned linear programming.
Just in case, I have my license of MATLAB. I just have this question and I didn't find any information. I wouldn't like to create another account, for this reason I prefer to ask here.
I have submitted a problem in cody some days back. Now it is not showing in my profile. Initially it was accepted and some people submitted the solutions also, however It has been removed after that, are there some guidelines which I am not following?
Hi everyone
I am a new of this community and I very interested in this forum and Matlab.I am trying to submit a soultion but as tiltle my code has a built-in function so the test systerm dont reconisie it.It run completely ok on my computer.
This is problem
This is my solution
function [boOut] = BoIfPointInPoly(PolyMatrix,p_test)
%Summary of this function goes here
%{
if we draw a line from test point to a central point of a side of The polygon
then we extend that line to the furthest point of the polygon ensure that
line go through all side of Polygon in 1 direction.I call that line is line_test
Next find number of intersert of line test and all sides w polyxpoly
function
num interset point is odd mean p_test inside
num interset point is even mean p_test outside
this solution go from the concept that if a line go in from a side it has go out
from other side.So if it go in but not go out that mean it start from
inside.
%}
% Detailed explanation goes here
%line from p test throuh central of a side to furthest point of polygon
%find vector
V = ((PolyMatrix(1,:) + PolyMatrix(2,:)) /2) - p_test ;
%draw that vector to furtest point
pend = p_test + V * max(PolyMatrix(:));
%with multi of V and biggest element I assume that line will go all out the
%polygon which ensure out logic will right
line_test = [p_test ; pend];
disp('Our line test\n');
disp(line_test);
%find interst point
p_inter = polyxpoly(PolyMatrix(:,1),PolyMatrix(:,2),line_test(:,1),line_test(:,2));
%find number of interset (row)
[numIntere,trash] = size(p_inter);
disp('Number of interest point:');
disp(numIntere);
%determine in or out
if (rem(numIntere,2) == 0)
boOut = 0;
else
boOut = 1;
end
end
Can anyone has solution.