Why do I get odd 0,0 point in Octave trisurf - octave
I am trying to draw a surface from a file on disk (shown below). But I get an odd additional point at co-ords (0,0).
The file appears to be in correct shape to me.
I draw the chart from my C# application with a call to Octave .Net. Here is the Octave part of the script:
figure (1,'name','Map');
colormap('hot');
t = dlmread('C:\Map3D.csv');
# idx = find(t(:,4) == 4.0);t2 = t(idx,:);
tx =t(:,1);ty=t(:,2);tz=t(:,3);
tri = delaunay(tx,ty);
handle = trisurf(tri,tx,ty,tz);xlabel('Floor');ylabel('HurdleF');zlabel('Sharpe');
waitfor(handle);
This script is called from my C# app, with the following , very simple, code snippet:
using (var octave = new OctaveContext())
{
octave.Execute(script, int.MaxValue);
}
Can anyone explain if my Octave script is wrong, or the way I have structured the file.
Floor,HurdleF,Sharpe,Model
1.40000000,15.00000000,-0.44,xxx1.40_Hrd_15.00
1.40000000,14.00000000,-0.49,xxx1.40_Hrd_14.00
1.40000000,13.00000000,-0.19,xxx1.40_Hrd_13.00
1.40000000,12.00000000,-0.41,xxx1.40_Hrd_12.00
1.40000000,11.00000000,0.42,xxx1.40_Hrd_11.00
1.40000000,10.00000000,0.17,xxx1.40_Hrd_10.00
1.40000000,9.00000000,0.28,xxx1.40_Hrd_9.00
1.40000000,8.00000000,0.49,xxx1.40_Hrd_8.00
1.40000000,7.00000000,0.45,xxx1.40_Hrd_7.00
1.40000000,6.00000000,0.79,xxx1.40_Hrd_6.00
1.40000000,5.00000000,0.56,xxx1.40_Hrd_5.00
1.40000000,4.00000000,1.76,xxx1.40_Hrd_4.00
1.30000000,15.00000000,-0.46,xxx1.30_Hrd_15.00
1.30000000,14.00000000,-0.55,xxx1.30_Hrd_14.00
1.30000000,13.00000000,-0.24,xxx1.30_Hrd_13.00
1.30000000,12.00000000,0.35,xxx1.30_Hrd_12.00
1.30000000,11.00000000,0.08,xxx1.30_Hrd_11.00
1.30000000,10.00000000,0.63,xxx1.30_Hrd_10.00
1.30000000,9.00000000,0.83,xxx1.30_Hrd_9.00
1.30000000,8.00000000,0.21,xxx1.30_Hrd_8.00
1.30000000,7.00000000,0.55,xxx1.30_Hrd_7.00
1.30000000,6.00000000,0.63,xxx1.30_Hrd_6.00
1.30000000,5.00000000,0.93,xxx1.30_Hrd_5.00
1.30000000,4.00000000,2.50,xxx1.30_Hrd_4.00
1.20000000,15.00000000,-0.40,xxx1.20_Hrd_15.00
1.20000000,14.00000000,-0.69,xxx1.20_Hrd_14.00
1.20000000,13.00000000,0.23,xxx1.20_Hrd_13.00
1.20000000,12.00000000,0.56,xxx1.20_Hrd_12.00
1.20000000,11.00000000,0.22,xxx1.20_Hrd_11.00
1.20000000,10.00000000,0.56,xxx1.20_Hrd_10.00
1.20000000,9.00000000,0.79,xxx1.20_Hrd_9.00
1.20000000,8.00000000,0.20,xxx1.20_Hrd_8.00
1.20000000,7.00000000,1.09,xxx1.20_Hrd_7.00
1.20000000,6.00000000,0.99,xxx1.20_Hrd_6.00
1.20000000,5.00000000,1.66,xxx1.20_Hrd_5.00
1.20000000,4.00000000,2.23,xxx1.20_Hrd_4.00
1.10000000,15.00000000,-0.31,xxx1.10_Hrd_15.00
1.10000000,14.00000000,-0.18,xxx1.10_Hrd_14.00
1.10000000,13.00000000,0.24,xxx1.10_Hrd_13.00
1.10000000,12.00000000,0.70,xxx1.10_Hrd_12.00
1.10000000,11.00000000,0.31,xxx1.10_Hrd_11.00
1.10000000,10.00000000,0.76,xxx1.10_Hrd_10.00
1.10000000,9.00000000,1.24,xxx1.10_Hrd_9.00
1.10000000,8.00000000,0.94,xxx1.10_Hrd_8.00
1.10000000,7.00000000,1.09,xxx1.10_Hrd_7.00
1.10000000,6.00000000,1.53,xxx1.10_Hrd_6.00
1.10000000,5.00000000,2.41,xxx1.10_Hrd_5.00
1.10000000,4.00000000,2.16,xxx1.10_Hrd_4.00
1.00000000,15.00000000,-0.41,xxx1.00_Hrd_15.00
1.00000000,14.00000000,-0.24,xxx1.00_Hrd_14.00
1.00000000,13.00000000,0.33,xxx1.00_Hrd_13.00
1.00000000,12.00000000,0.18,xxx1.00_Hrd_12.00
1.00000000,11.00000000,0.61,xxx1.00_Hrd_11.00
1.00000000,10.00000000,0.96,xxx1.00_Hrd_10.00
1.00000000,9.00000000,1.75,xxx1.00_Hrd_9.00
1.00000000,8.00000000,0.74,xxx1.00_Hrd_8.00
1.00000000,7.00000000,1.63,xxx1.00_Hrd_7.00
1.00000000,6.00000000,2.12,xxx1.00_Hrd_6.00
1.00000000,5.00000000,2.73,xxx1.00_Hrd_5.00
1.00000000,4.00000000,2.03,xxx1.00_Hrd_4.00
0.90000000,15.00000000,-0.42,xxx0.90_Hrd_15.00
0.90000000,14.00000000,-0.37,xxx0.90_Hrd_14.00
0.90000000,13.00000000,0.58,xxx0.90_Hrd_13.00
0.90000000,12.00000000,0.03,xxx0.90_Hrd_12.00
0.90000000,11.00000000,0.68,xxx0.90_Hrd_11.00
0.90000000,10.00000000,0.79,xxx0.90_Hrd_10.00
0.90000000,9.00000000,1.54,xxx0.90_Hrd_9.00
0.90000000,8.00000000,0.82,xxx0.90_Hrd_8.00
0.90000000,7.00000000,1.81,xxx0.90_Hrd_7.00
0.90000000,6.00000000,2.33,xxx0.90_Hrd_6.00
0.90000000,5.00000000,2.99,xxx0.90_Hrd_5.00
0.90000000,4.00000000,1.71,xxx0.90_Hrd_4.00
0.80000000,15.00000000,-0.46,xxx0.80_Hrd_15.00
0.80000000,14.00000000,-0.26,xxx0.80_Hrd_14.00
0.80000000,13.00000000,0.55,xxx0.80_Hrd_13.00
0.80000000,12.00000000,0.07,xxx0.80_Hrd_12.00
0.80000000,11.00000000,0.65,xxx0.80_Hrd_11.00
0.80000000,10.00000000,1.08,xxx0.80_Hrd_10.00
0.80000000,9.00000000,1.27,xxx0.80_Hrd_9.00
0.80000000,8.00000000,1.12,xxx0.80_Hrd_8.00
0.80000000,7.00000000,1.98,xxx0.80_Hrd_7.00
0.80000000,6.00000000,2.62,xxx0.80_Hrd_6.00
0.80000000,5.00000000,3.35,xxx0.80_Hrd_5.00
0.80000000,4.00000000,1.27,xxx0.80_Hrd_4.00
0.70000000,15.00000000,-0.56,xxx0.70_Hrd_15.00
0.70000000,14.00000000,-0.33,xxx0.70_Hrd_14.00
0.70000000,13.00000000,0.24,xxx0.70_Hrd_13.00
0.70000000,12.00000000,-0.22,xxx0.70_Hrd_12.00
0.70000000,11.00000000,0.74,xxx0.70_Hrd_11.00
0.70000000,10.00000000,1.19,xxx0.70_Hrd_10.00
0.70000000,9.00000000,1.24,xxx0.70_Hrd_9.00
0.70000000,8.00000000,1.14,xxx0.70_Hrd_8.00
0.70000000,7.00000000,2.26,xxx0.70_Hrd_7.00
0.70000000,6.00000000,2.70,xxx0.70_Hrd_6.00
0.70000000,5.00000000,3.52,xxx0.70_Hrd_5.00
0.70000000,4.00000000,1.05,xxx0.70_Hrd_4.00
0.60000000,15.00000000,-0.50,xxx0.60_Hrd_15.00
0.60000000,14.00000000,-0.60,xxx0.60_Hrd_14.00
0.60000000,13.00000000,0.11,xxx0.60_Hrd_13.00
0.60000000,12.00000000,-0.16,xxx0.60_Hrd_12.00
0.60000000,11.00000000,0.73,xxx0.60_Hrd_11.00
0.60000000,10.00000000,1.08,xxx0.60_Hrd_10.00
0.60000000,9.00000000,1.31,xxx0.60_Hrd_9.00
0.60000000,8.00000000,1.38,xxx0.60_Hrd_8.00
0.60000000,7.00000000,2.24,xxx0.60_Hrd_7.00
0.60000000,6.00000000,2.89,xxx0.60_Hrd_6.00
0.60000000,5.00000000,3.50,xxx0.60_Hrd_5.00
0.60000000,4.00000000,1.11,xxx0.60_Hrd_4.00
0.50000000,15.00000000,-0.40,xxx0.50_Hrd_15.00
0.50000000,14.00000000,-0.37,xxx0.50_Hrd_14.00
0.50000000,13.00000000,0.13,xxx0.50_Hrd_13.00
0.50000000,12.00000000,-0.11,xxx0.50_Hrd_12.00
0.50000000,11.00000000,0.61,xxx0.50_Hrd_11.00
0.50000000,10.00000000,0.92,xxx0.50_Hrd_10.00
0.50000000,9.00000000,1.41,xxx0.50_Hrd_9.00
0.50000000,8.00000000,1.39,xxx0.50_Hrd_8.00
0.50000000,7.00000000,2.19,xxx0.50_Hrd_7.00
0.50000000,6.00000000,2.80,xxx0.50_Hrd_6.00
0.50000000,5.00000000,3.41,xxx0.50_Hrd_5.00
0.50000000,4.00000000,1.05,xxx0.50_Hrd_4.00
0.40000000,15.00000000,-0.25,xxx0.40_Hrd_15.00
0.40000000,14.00000000,-0.44,xxx0.40_Hrd_14.00
0.40000000,13.00000000,0.02,xxx0.40_Hrd_13.00
0.40000000,12.00000000,0.00,xxx0.40_Hrd_12.00
0.40000000,11.00000000,0.69,xxx0.40_Hrd_11.00
0.40000000,10.00000000,0.67,xxx0.40_Hrd_10.00
0.40000000,9.00000000,1.02,xxx0.40_Hrd_9.00
0.40000000,8.00000000,1.29,xxx0.40_Hrd_8.00
0.40000000,7.00000000,2.17,xxx0.40_Hrd_7.00
0.40000000,6.00000000,2.88,xxx0.40_Hrd_6.00
0.40000000,5.00000000,3.19,xxx0.40_Hrd_5.00
0.40000000,4.00000000,0.98,xxx0.40_Hrd_4.00
0.30000000,15.00000000,-0.02,xxx0.30_Hrd_15.00
0.30000000,14.00000000,-0.36,xxx0.30_Hrd_14.00
0.30000000,13.00000000,-0.26,xxx0.30_Hrd_13.00
0.30000000,12.00000000,-0.11,xxx0.30_Hrd_12.00
0.30000000,11.00000000,0.50,xxx0.30_Hrd_11.00
0.30000000,10.00000000,0.50,xxx0.30_Hrd_10.00
0.30000000,9.00000000,1.01,xxx0.30_Hrd_9.00
0.30000000,8.00000000,1.28,xxx0.30_Hrd_8.00
0.30000000,7.00000000,2.11,xxx0.30_Hrd_7.00
0.30000000,6.00000000,2.89,xxx0.30_Hrd_6.00
0.30000000,5.00000000,3.16,xxx0.30_Hrd_5.00
0.30000000,4.00000000,0.95,xxx0.30_Hrd_4.00
What's happening
dlmread() is reading the file in as numeric data and returning a numeric matrix. It doesn't recognize the text in your header line, so it silently converts that row to all zeros. (IMHO this is a design flaw in dlmread.) Remove the header line.
How to debug this
So, you've got some zeros in your plot that you didn't expect to be there? Check for zeros in your input data:
ixZerosX = find(tx == 0)
ixZerosY = find(ty == 0)
ixZerosZ = find(tz == 0)
The semicolons are omitted intentionally there to get Octave to automatically display the results.
Better yet, since doubles are an approximate type, and the values might be close to but not actually zero, do a "near zero" search:
threshold = 0.1;
ixZerosX = find(abs(tx) < threshold)
ixZerosY = find(abs(ty) < threshold)
ixZerosZ = find(abs(tz) < threshold)
Related
Extracting color from complex function: " Cannot modify global variable 'cColor' in function."
I'd like to extract the "col" color value from this function to be used to paint plots or candle colors. But everything I try creates one error or another. I checked the Script Reference. Shouldn't there be some way to "return" a value, as is usually the case with most functions? lset(l,x1,y1,x2,y2,col)=> line.set_xy1(l,x1,y1) line.set_xy2(l,x2,y2) line.set_width(l,5) line.set_style(l, line.style_solid) line.set_color(l,y2 > y1 ? #ff1100 : #39ff14) //red : green temp = line.get_price(l,bar_index) // another value to extract
The documentation is showing it like this: line.new(x1, y1, x2, y2, xloc, extend, color, style, width) → series line So in your code it's looking differently and also the "new" is missing. Scrolling a bit up on the linked page shows that there exist indeed methods to retrieve some properties of the line object: Lines are managed using built-in functions in the line namespace. They include: line.new() to create them. line.set_*() functions to modify the properties of an line. line.get_*() functions to read the properties of an existing line. line.copy() to clone them. line.delete() to delete them. The line.all array which always contains the IDs of all the visible lines on the chart. The array’s size will depend on the maximum line count for your script and how many of those you have drawn. aray.size(line.all) will return the array’s size. The most simple usage is to instantiate a line object with the correct values directly, like shown here: //#version=5 indicator("Price path projection", "PPP", true, max_lines_count = 100) qtyOfLinesInput = input.int(10, minval = 1) y2Increment = (close - open) / qtyOfLinesInput // Starting point of the fan in y. lineY1 = math.avg(close[1], open[1]) // Loop creating the fan of lines on each bar. for i = 0 to qtyOfLinesInput // End point in y if line stopped at current bar. lineY2 = open + (y2Increment * i) // Extrapolate necessary y position to the next bar because we extend lines one bar in the future. lineY2 := lineY2 + (lineY2 - lineY1) lineColor = lineY2 > lineY1 ? color.lime : color.fuchsia line.new(bar_index - 1, lineY1, bar_index + 1, lineY2, color = lineColor) Getting the line color from outside is difficult or impossible though as there never exists a method to retrieve it while for other properties those methods exist. So the most simple way is to create the same funcionality, to get the color that exists inside the line-object, outside too, or only outside. currentLineColor = y2 > y1 ? #ff1100 : #39ff14 You could try to extend the line-object somehow like this: line.prototype.get_color = function() { return this.color; }; console.log(line.get_color()) I'm not sure if the approach with the prototype is working but it's worth it to try if you need it.
Octave axes zoom redraw
I am facing an issue in Octave. When I set custom tick labels of y axis, labels are not updated correctly when zoomed. It is easy to solve in Matlab: plot(1:10); ax = gca; ax.YAxis.TickLabelFormat = '%,.1f'; My code with faulty y labels when zoomed: ax2 = gca; ytick = get (ax2, "ytick"); yticklabel = strsplit (sprintf ("%9.0f\n", ytick), "\n", true); set (ax2, "yticklabel", yticklabel); The above code formats y tick labels properly, but labels does not match plot when zoomed. There is a screenshot of my issue: nonzoomed vs zoomed. I am using W10 64bit, Octave version 4.0.3.. Octave was configured for "i686-w64-mingw32". Any ideas? I have decided to add minimal code example to be more clear about the issue: x=1:length(inv); figure hax1 = subplot(2,1,1); stairs(x,inv); hax2 = subplot(2,1,2); x=1:length(mon); % big numbers here, need to format to get rid of scientific notation stairs(x,mon); ax2 = gca; ytick = get (ax2, "ytick"); yticklabel = strsplit (sprintf ("%9.0f\n", ytick), "\n", true); set (ax2, "yticklabel", yticklabel); linkaxes([hax1 hax2],'x');
RangeError: Error #2006: The supplied index is out of bounds AS3
I've loved using this site for little tips on code, and I try to solve all the errors I can by myself. However, this one has had me stumped for days. I just can't crack it. RangeError: Error #2006: The supplied index is out of bounds. at flash.text::TextField/setTextFormat() at BibleProgram_fla::MainTimeline/checkAgainstBible() at BibleProgram_fla::MainTimeline/compileInputString() at BibleProgram_fla::MainTimeline/spaceBuild() function spaceBuild(event:Event):void //This program runs every frame { compileInputString(); } function compileInputString():void { inputVerse = inputText.text; // takes text from the input field inputVerse = inputVerse.toLowerCase(); inputVerse = inputVerse.replace(rexWhiteSpace, ""); //Removes spaces and line breaks inputVerse = inputVerse.replace(rexPunc, ""); // Removes punctuation inputVerse = addSpaces(inputVerse); //adds spaces back in to match the BibleVerse inputVerse = addCaps(inputVerse); //adds capitalization to match the BibleVerse checkAgainstBible(); } function checkAgainstBible() { outputText.text = inputVerse; // sets output text to be formatted to show which letters are wrong for(var n:Number = 0; n < inputText.length; n++) { var specLetter:String = inputVerse.charAt(n); if(specLetter != bibleVerse.charAt(n)) { outputText.setTextFormat(red, n); // sets all of the wrong letters to red } } } Whenever I run the program and type a string longer than the BibleVerse, it returns the error, but I cannot figure out how to fix it. I hope I provided enough information for you to help me. If you need more code or something, please ask! Thanks in advance!!
Well, you would get that error if n is greater than the number of characters in the outputText when it sets its format color to red, and it looks like your outputText's characters are extended or shortened when you make it equal to your inputVerse because inputVerse had all the regex operations that i can't seen done to it. So most likely these operations are shortening the characters and so outputText.text is shorter than it should be and when it loops over the inputText.length, when it gets to the end of the outputText, n goes past its character length and so you get that error (That is what the error is - you are attempting to access something that is not there). So the way i see it is (using example made up strings); // Pseudo code... inputVerse=inputText.text; // (lets say its "Thee ") // inputVerse and inputText.text now both have 5 characters inputVerse=lotsOfOperations(inputVerse); // inputVerse now only has 4 characters (got rid of the " " at the end) outputText.text=inputVerse; // outputText.text now has the new 4 character for(var n:Number = 0; n < inputText.length; n++) // loops through inputText.length (so it loops 5 times) outputText.setTextFormat(red, n); // if n=4 (since n starts at 0) from the inputText.length, then when it access //outputText.setTextFormat(red,n) it is accessing a character of outputText.text //that is at the end and not there. outputText.text is too short for the loop. So, your problem is that your operations to inputVerse are making it too short to compare to the other strings, I don't know your other code so I can't say whats wrong, but this is why you are getting the error. Please comment if you have any questions or to notify me of what I am missing.
error in reading csv file to plot graph
i am just not able to read a csv file .I want to display a graph for it. I am getting error: TypeError: n is undefined please help me out!! d3.csv("example.csv", function(dataset){ var svg=d3.select("body").append("svg").attr("width",w).attr("height",h); var xScale=d3.scale.ordinal().domain(d3.range(dataset.length)).rangeRoundBands([0,w],0.05); var yScale=d3.scale.linear().domain([0,d3.max(dataset.value)]).range([0,h]); svg.selectAll("rect").data(dataset).enter().append("rect").attr({x:function(d,i) {return xScale(i);}, y:function(d){ return h-yScale(d);}, width:xScale.rangeBand(),height:function(d){return yScale(d);},fill:function(d){return "rgb(0,0,"+(d.value*10)+")";}}); d3.select("svg").selectAll("text").data(dataset).enter().append("text").text(function(d) {return d.value;}).attr("x",function(d,i){ return xScale(i)+xScale.rangeBand()/2;}).attr("y",function(d){return h-yScale(d)+14;}).attr("font-family","sans-serif").attr("font-size","10px").attr ("fill","white").attr("text-anchor","middle"); d3.select("p").on("click",function(){ var numValues=dataset.length; dataset=[]; for(var i=0;i<numValues;i++) {var newNumber=Math.floor(Math.random()*25); dataset.push(newNumber,newNumber); } yScale.domain([0,d3.max(dataset)]); svg.selectAll("rect").data(dataset).transition().delay(function(d,i){return i/dataset.length*1000;}) .duration(500).attr("y",function(d){return h-yScale(d); }).attr("height",function(d) {return yScale(d);}).attr("fill",function(d){ return "rgb(0,0,"+(d.value*10)+")";}); svg.selectAll("text").data(dataset).transition().delay(function(d,i){return i/dataset.length*1000;}).duration(500).text(function(d){return d.value;}) .attr("x",function(d,i){return xScale(i)+xScale.rangeBand()/2;}).attr("y",function(d) {return h-yScale(d)+14;}) .attr("font-family","sans-serif").attr("font- size","10px").attr("fill","white").attr("text-anchor","middle") ;}); }); here is my csv file names,value john,78 brad,105 amber,103 james,2 dean,74 pat,45 matt,6 andrew,18 ashley,15
As mentioned by cuckovic there are quite a few errors in your code, not to mention that you seem to be using different styles to achieve similar things which is confusing. Anyway there are 3 fundamental things that are casuing you trouble, the first is your dataset. The value column of the csv is being read as a string. You need to convert it to a number by: dataset.forEach(function (d,i) { d.value = +d.value; }); The next issue you have is the yScale where you have set the range to .range([0,h]);. This is the wrong way round for an svg viewport in which the y direction starts from top and increases towards the bottom. So you need to swap the 0 and h around in the range. The next thing to address is the difference between d and d.value. When you bind data through the data() operator you are generally binding an array. In this case it is an array of objects. So after you have bound the data, d refers to each element of that array which in this case is an object containing a name and a value. This can be seen if you console.log your dataset. When d is passed to yScale it doesn't know what to do with it as it is not a number, what you really want to do is to pass d.value to yScale. So replace your d's with d.value. Finally, the last part of your code starting at d3.select("p") does not seem to add anything. I'd recommend reading Scott Murray's tutorials, particularly this one if you haven't already.
How do I set a function to a variable in MATLAB
As a homework assignment, I'm writing a code that uses the bisection method to calculate the root of a function with one variable within a range. I created a user function that does the calculations, but one of the inputs of the function is supposed to be "fun" which is supposed to be set equal to the function. Here is my code, before I go on: function [ Ts ] = BisectionRoot( fun,a,b,TolMax ) %This function finds the value of Ts by finding the root of a given function within a given range to a given %tolerance, using the Bisection Method. Fa = fun(a); Fb = fun(b); if Fa * Fb > 0 disp('Error: The function has no roots in between the given bounds') else xNS = (a + b)/2; toli = abs((b-a)/2); FxNS = fun(xns); if FxNS == 0 Ts = xNS; break end if toli , TolMax Ts = xNS; break end if fun(a) * FxNS < 0 b = xNS; else a = xNS; end end Ts end The input arguments are defined by our teacher, so I can't mess with them. We're supposed to set those variables in the command window before running the function. That way, we can use the program later on for other things. (Even though I think fzero() can be used to do this) My problem is that I'm not sure how to set fun to something, and then use that in a way that I can do fun(a) or fun(b). In our book they do something they call defining f(x) as an anonymous function. They do this for an example problem: F = # (x) 8-4.5*(x-sin(x)) But when I try doing that, I get the error, Error: Unexpected MATLAB operator. If you guys want to try running the program to test your solutions before posting (hopefully my program works!) you can use these variables from an example in the book: fun = 8 - 4.5*(x - sin(x)) a = 2 b = 3 TolMax = .001 The answer the get in the book for using those is 2.430664. I'm sure the answer to this is incredibly easy and straightforward, but for some reason, I can't find a way to do it! Thank you for your help.
To get you going, it looks like your example is missing some syntax. Instead of either of these (from your question): fun = 8 - 4.5*(x - sin(x)) % Missing function handle declaration symbol "#" F = # (x) 8-4.5*(x-sin9(x)) %Unless you have defined it, there is no function "sin9" Use fun = #(x) 8 - 4.5*(x - sin(x)) Then you would call your function like this: fun = #(x) 8 - 4.5*(x - sin(x)); a = 2; b = 3; TolMax = .001; root = BisectionRoot( fun,a,b,TolMax ); To debug (which you will need to do), use the debugger. The command dbstop if error stops execution and opens the file at the point of the problem, letting you examine the variable values and function stack. Clicking on the "-" marks in the editor creates a break point, forcing the function to pause execution at that point, again so that you can examine the contents. Note that you can step through the code line by line using the debug buttons at the top of the editor. dbquit quits debug mode dbclear all clears all break points