clear num = [1 1 1 1 1 1 1]; den = [1 2 3 0 5 6 7]; for i = 1: numel(den) if den(i) == 0 a = 1 else … 続きを読む >>
Debugging session 3
- カテゴリ:
- Format: Video,
- Level: Basic
clear num = [1 1 1 1 1 1 1]; den = [1 2 3 0 5 6 7]; for i = 1: numel(den) if den(i) == 0 a = 1 else … 続きを読む >>
A statement like this: a = sin(x) + cos(y) + inv(z); makes it impossible to know which part of the calculation is the bottleneck. This video shows how to determine what is slowing your code… 続きを読む >>
I have been reading the MATLAB questions in Stack Overflow for a few weeks, and here was a really good question that came through. With two vectors, x and y, bin the x values as if with a… 続きを読む >>
A question came up on the MATLAB newsgroup about debugging a sorting algorithm. I thought this was an excellent opportunity to show how visualization of intermediate results would help to determine… 続きを読む >>
The MATLAB user has this: clear clc M(:,:,1) = [1,2;3,4]; M(:,:,2) = [21,22;23,24]; J = [1,2; 2,1]; They want this: ans = [1 22 23 4] They tried this: D = M(:,:,J) % This doesn’t… 続きを読む >>
Talking through your code is an excellent way to find bugs. By discussing the code you have written line by line, you are forced to understand it better. This is a common practice at most software… 続きを読む >>
Sometimes you will do a calculation where the answer looks like ‘0’ or ‘1’ or some other number like that. The natural thing to do is to do a test like this: if (answer ==… 続きを読む >>
In this short video, I explore the math behind this joke: An infinite number of mathematicians walk into a bar. The 1st orders a 1 beer. The 2nd orders 1/2 a beer. The 3rd orders … 続きを読む >>
I love getting well formed question and challenges from fellow MATLAB users. This week I got one that works very well as a video. The problem was trying to index into a vector with a vector of… 続きを読む >>
I think it is best to do these tutorials based on solving realistic coding challenges. In helping to write the code for the next MATLAB contest, I had a situation where I wanted two images to be… 続きを読む >>