File Exchange Pick of the Week

March 29th, 2006

Linearly space matrix

This week’s guest pick of the week comes from Brett Shoelson of CSSM fame and one of the newer Language of Technical Computing Applications Engineers here at The Mathworks. Applications Engineers present a lot of live seminars, maybe you can meet Brett at his next event and ask him some really tough questions!

Let’s say that you wanted to create a linearly spaced vector of elements ranging from scalar x1 to scalar x2; MATLAB’s own linspace.m function was built for that purpose, and makes it a trivial problem. But what if instead you wanted to step from vector X1 to (same-sized) vector X2 in a given number of steps? Or more dauntingly, consider the task of uniformly incrementing the elements of N-dimensional matrix M1 to the equal-sized matrix M2 in a specified number of steps. Certainly there are several ways to approach the problem, but none is particularly easy. Until, that is, you download Duane Hanselman’s linspacen, which, with some very nice code, makes short work of the problem. Duane has also provided the functionality to step logarithmically in N dimensions, expanding the functionality of MATLAB’s logspace function. The pair, linspacen and logspacen, together comprise this week’s Pick of the Week.

2 Responses to “Linearly space matrix”

  1. Siamak replied on :

    Hi Doug, I’m a MATLAB programmer, I was wondering if I can have a weblog on MATWORKS website (do I have to be a MATHWORKS employee to get a weblog here????)

    Have a nice day
    -Siamak
    http://www.pitchup.com

  2. Doug replied on :

    The MathWorks blogs are one of the perks of being a MathWorker. Some people use their File Exchange profiles to link to their blogs. Also, if you have ideas for code that should be used for Pick of the week, please let me know and I will check it out (even if it is your own). I can credit you for the find.

Leave a Reply

Wrap code fragments inside <pre> tags, like this:

<pre class="code">
a = magic(3);
sum(a)
</pre>

If you have a "<" character in your code, either follow it with a space or replace it with "&lt;" (including the semicolon).


Bob, Brett & Jiro share their favorite user-contributed submissions from the File Exchange.

  • Zach: Hi Doug and Les, I didn’t have a lot of time to mess with this, but I did find a work-around. I plotted...
  • hamed: k
  • Les: @Zach This isn’t exactly what you are looking for but at least it puts all three parameters on the same...
  • Zach: Thanks for your suggestions Doug. I’ll give that a shot and see what happens. I’ve seen many of...
  • Doug: @Zach, I would say to use plotYYY, because that is close to what you want, but using depth as Y makes sense....
  • Doug: @Teja, I think this will work: http://www.mathworks .com/access/helpdesk /help/techdoc/ref...
  • Gify: merry christmas :) nice christmas tree! Regards, Janet Gify
  • Teja: Dear Doug Is there anyway to plot a surface from nonuniform data without meshgrid and griddata? Basically i...
  • Zach: I’m working with geophysical data, so I’d like to produce a depth profile. The y-axis would be...
  • Doug: @Ashok First, please do not use variable names that are MATLAB commands (std and mean). Second, p(j) should be...

These postings are the author's and don't necessarily represent the opinions of The MathWorks.