Answered
Need help With "If" statement
Do you want that to be an error condition? In which case |error('no')| (in place of |disp|) will display the message and termin...

15 years ago | 0

Answered
Numerical integration while keeping the parameters
Or, if it's actually a function of x with two parameters, and integrated over a fixed interval, then a variation of Andrew's ans...

15 years ago | 1

| accepted

Answered
Problem keeping input file in the same order using textscan
Ahahahahaha! I'm gonna take a bet that price(1) is actually the price from the 49th row, right? You'll love this. Instead o...

15 years ago | 2

| accepted

Answered
Output from handles instead of globals
If these functions all live in the same file, the simplest way to pass data around is to use nested functions. A nested functio...

15 years ago | 0

Answered
Need help with Plots
Or is the problem that the colors should cover the whole map (instead of a small box in the middle)? In which case the problem ...

15 years ago | 0

| accepted

Answered
Need help with Plots
It's hard to tell exactly from the image, but it looks like maybe it's just the lines that make it look like a black box. Try t...

15 years ago | 0

Answered
Create a function to find the average of an entire matrix only using loops
Why the requirement for a loop? The neatest way to do this is: mean(x(:)) But if you really want a loop, function ...

15 years ago | 0

Answered
Summing across columns
Just a simplification to Paulo's version -- "plot against the first column" means plot the sum as y and the first column as x: ...

15 years ago | 1

Answered
Having Trouble Plotting 4D data
I concur with Andrew about the code. Another diagnostic you could use is to visualize a series of slices: figure for k = 1...

15 years ago | 0

Answered
How do I keep a handle and use FINDOBJ to get a handle again?
What Matt Fig said, plus: are you actually copying the number in (rather than saving it in a variable and passing the variable i...

15 years ago | 3

| accepted

Answered
Segmented Sinewave
Something like this? p = 3; t = linspace(0,10*p,201); tseg = p*[0 1 4 5:9]; n = length(tseg)-1; y = sin(2*pi*t)...

15 years ago | 0

Answered
Is cellfun multithreaded or does it do the operation one cell at a time?
Currently |cellfun| is not multithreaded.

15 years ago | 3

Answered
Problem with conditional code and missing data
You can use size -- note: |size(x,1)| returns the number of rows [dimension 1], and |size(x,2)| returns the number of columns [d...

15 years ago | 0

Answered
What do you like about MATLAB?
\ It takes getting a little used to, but once you grok it... ( |/| too, but it's not as useful as |\|). The fact that it h...

15 years ago | 0

Answered
clear one plot in multiple (hold) figure
In addition to the cyclist's answer, you can also do delete(h2) to actually delete the line, rather than just hide it. ...

15 years ago | 50

Answered
What do you like about MATLAB?
Logical indexing is proof that Cleve loves us and wants us to be happy. Eg, goodbye outliers: x(x > val) = [] Or stats ...

15 years ago | 6

Answered
Calculate derivatives on the interval 0<x<2pi using forward, backward, centered, and fourth order accurate finite differences
First, those |for| loops are making Baby Cleve cry. They can all be replaced with vectorized expressions ( |f = a*x + b*x.^2 +|...

15 years ago | 0

| accepted

Answered
[DISCONTINUED] Wish-list for MATLAB Answer sections.
An automated email: "Dear [user], than you for using MATLAB Answers. Your question "[title]" now has [num_ans] answers. If any...

15 years ago | 7

Answered
Multiple f(x) values for a 2D graphic
For more than two y axes, you could try <http://www.mathworks.com/matlabcentral/fileexchange/4425-ploty4-m ploty4.m> or <http://...

15 years ago | 0

Answered
What programming challenges would you pose to new users?
Several of the problems at <http://projecteuler.net/index.php?section=problems Project Euler> have made me think about new ways ...

15 years ago | 1

Answered
Finding minima
If you want fancy, take Walter's advice and search FEx. If you want quick and dirty: x = 1:50; y = sin(5*x); idx = [...

15 years ago | 4

| accepted

Answered
Can I get side-by-side-by-side barh on one axes?
What you've suggested already seems to solve the problem. So is the real issue that you've had to hack the values to start at 1...

15 years ago | 0

Answered
Read file
Or, using |textscan| (as Jan mentioned): FID = fopen(FileName, 'r'); if FID <= 0, error('Cannot open file'); end Data...

15 years ago | 0

Answered
How to display values with formatting, converting numbers to strings.
Try this (as a cut/paste replacement of the code you posted): if size(cost,1) == 2 A = (4*Pdt*cost(1,3)*cost(2,3))...

15 years ago | 0

Answered
Removal of duplicate entries and counting them
*If* you happen to have access to Statistics Toolbox, and you are actually messing with strings (like in your example), you migh...

15 years ago | 1

Answered
How to display values with formatting, converting numbers to strings.
function multilinetext hf = figure; uicontrol(hf,'style','pushbutton','string','update',... 'position',[100,100,6...

15 years ago | 0

Answered
Solving the scaling problem.
If it's just two vectors then you could do A = x2(1)/x1(1) norm(A*x1 - x2) A slightly more generalizable way is ...

15 years ago | 1

Answered
[DISCONTINUED] Wish-list for MATLAB Answer sections.
Has anyone else been tripped up by the auto-folded comments? I'd personally prefer expanded by default, or at least a higher th...

15 years ago | 3

Answered
How to display values with formatting, converting numbers to strings.
If I interpret your question correctly, you're asking how to get the nicely formatted output in the text box. If that's the cas...

15 years ago | 0

Load more