Answered
Error when using validatestring in inputParser addOptional
Hi Kevin, The problem lies in _validatestring_... from the docs: "the validatestring function returns the matching string in ...

14 years ago | 0

| accepted

Answered
How can I skip lines when loading a text file?
Hi Baba, try importdata: importdata(FILENAME, DELIM, NHEADERLINES) loads data from ASCII file FILENAME, reading numeric ...

14 years ago | 0

Answered
push button to change a variable
Hi Sven (nice name, btw), here's what I think you're looking for. Try making a myFunction.m file with the contents below, the...

14 years ago | 0

| accepted

Answered
Reading a CSV file with header and times
Hi Steven, The string you've got for the dates and times aren't automatically recognised as simple dates - you'll need to rea...

14 years ago | 1

| accepted

Answered
Numerical packing
Thank you Sean, Elige, for your responses, and thanks Walter for naming the problem I'd posed. Even after seeing it as a "knapsa...

14 years ago | 0

| accepted

Question


Numerical packing
Hi all, here's a quick one. I've got an array and a limit: A = [235 235 235 234 235 235 234 234 234 220 280 215 234] lim = ...

14 years ago | 5 answers | 2

5

answers

Answered
changing color and x-axis ticks in barplot
JW, try this: h = bar(rand(1,3)) set(gca,'XTickLabel',{'One','Two','Three'}) Setting different colours for each bar is a l...

14 years ago | 2

Answered
how to use output indexes from the MAX function
Hi Patrick, I think this is what you want to do: arrSz = [5 6 7]; % Size of matrix cube1 = 10*rand(arrSz);...

14 years ago | 1

| accepted

Answered
Matrix Sum
You can (and possibly should, depending on what you want to do next) turn your N 3-by-3 matrices into a single 3-by-3-by-N matri...

14 years ago | 0

Answered
Imagesc & plot matrix
Salvatore, try this: Im = [1.0000 0.7944 0.7361 0.8205 0.4192 0.7944 1.0000 0.8663 0.6780 0.3435 ...

14 years ago | 1

| accepted

Answered
Filling the objects found by canny edge
Kasia, I wrote the following, which does what (I think) you're looking for: I = imread('di-HQA6.jpg'); BW = bwareaopen(a...

14 years ago | 0

| accepted

Answered
Return the number of rows of an array of cell data
If your cell contains strings (and not numeric data), just use *strcmp*: [row,col] = find(strcmp('Temp Height (density)', a...

14 years ago | 0

| accepted

Answered
creating an image using a matrix
Raldi, try this: % Define the image size and where you want the circle rows = 50; cols = 50; radius = 20; center = [2...

14 years ago | 2

| accepted

Answered
Replace nested loops?
A small time-drain will be the fact that inside the loop, the *overlap* variable gets constantly resized. In the MATLAB editor, ...

14 years ago | 0

| accepted

Answered
creating biomorph
As far as I'm aware, the "biomorphs" have not been implemented yet in MATLAB. There have been other Dawkins' evolutionary MATLAB...

14 years ago | 1

| accepted

Answered
strings, while loop help
Chris, try this: word = 'MyMatlab'; masked = repmat('*', size(word)); wrongGuesses = 0; wordGuessed = false; while w...

14 years ago | 1

| accepted

Answered
replace elements of a vector
Hi Tiina, try this. It uses *find* and *arrayfun* to replace the zero-values of A with the nearest preceding non-zero value: ...

14 years ago | 1

Answered
Display a variable and its units
You can use *fprintf* as follows: X = 25; fprintf('The answer is %d ft/lb\n', X) If your answer will not be a nice round n...

14 years ago | 5

Answered
Finding the indices of the elements of one array in another
There are a few options to get the indices you are looking for. The following output indices (idx) preserve the order in A of th...

14 years ago | 20

| accepted

Answered
Isopleth
Hi Karen, do you mean that you'd like to make a contour plot? You can try this (from the docs for *contour()*): Z = peaks; ...

14 years ago | 0

| accepted

Answered
How do I fix a improper index matrix reference error
Here's how to debug such a problem: Type into the command line: dbstop if error Then, run your program. MATLAB will *stop* ...

14 years ago | 0

Answered
Centroid Location is incorrect when edited in actual image data
One place where the code does something different to what I think you intended is here: blackwhite(centroids(:,1),centroids(:...

14 years ago | 1

| accepted

Answered
interpolating missing data
Let's start with your data. data = [1 2330000 5.92275000000000e-06 36.2000000000000 2 52900000 2.79773000000000e-07 35.2000...

14 years ago | 0

| accepted

Answered
Calculating and extracting data from three dimensional array
Almost there, Michael. Try this to average your two years: average = mean(testdata,3) This will average your testdata over t...

14 years ago | 0

| accepted

Answered
about saving the numerical value and string altogether
Hi Liangjian, try this to join your cell and numbers: myCell = {'asf','qwe';'wer','two';'opi','oei'}; myNums = rand(3,1); ...

14 years ago | 0

| accepted

Answered
Finding the position of the 1st,2nd and 3rd max value in a matrix
Hi Amin, try this: [sortedX, sortedInds] = sort(X(:),'descend'); top3 = sortedInds(1:3) And if you want to get the (i,j) r...

14 years ago | 8

Answered
?? Error using ==> mrdivide Matrix dimensions must agree.
*Rc* is empty (it gets initialised as a global variable but nothing is assigned to it), but it's used in your *calc=...* calcula...

14 years ago | 0

| accepted

Answered
ginput is turning off mouse cursor
Does the code by any chance rely on window events such as buttondownfcn, buttonmotionfcn, etc? *ginput()* has the annoying behav...

14 years ago | 0

| accepted

Answered
Want to limit the lines of output. (for example, output after every 1000 iterations)
Hi Brian, your loop has a number of places where arrays are growing inside a loop. I believe this is the main reason why your co...

14 years ago | 0

| accepted

Answered
deawing 3d vector lines
Hi Eve, you can use the following to draw a line from your original point in the direction specified. pt = [4 3 2] % Your p...

14 years ago | 0

Load more