Risposto
Plotting functions
MATLAB Answers is a place you can get help from the user community on specific MATLAB questions. It is not intended as a place ...

oltre 15 anni fa | 1

Risposto
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...

oltre 15 anni fa | 0

Risposto
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...

oltre 15 anni fa | 1

| accettato

Risposto
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...

oltre 15 anni fa | 2

| accettato

Risposto
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...

oltre 15 anni fa | 0

Risposto
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 ...

oltre 15 anni fa | 0

| accettato

Risposto
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...

oltre 15 anni fa | 0

Risposto
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 ...

oltre 15 anni fa | 0

Risposto
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: ...

oltre 15 anni fa | 1

Risposto
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...

oltre 15 anni fa | 0

Risposto
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...

oltre 15 anni fa | 3

| accettato

Risposto
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)...

oltre 15 anni fa | 0

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

oltre 15 anni fa | 3

Risposto
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...

oltre 15 anni fa | 0

Risposto
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...

oltre 15 anni fa | 0

Risposto
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. ...

oltre 15 anni fa | 50

Risposto
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 ...

oltre 15 anni fa | 6

Risposto
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 +|...

oltre 15 anni fa | 0

| accettato

Risposto
[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...

oltre 15 anni fa | 7

Risposto
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://...

oltre 15 anni fa | 0

Risposto
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 ...

oltre 15 anni fa | 1

Risposto
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 = [...

oltre 15 anni fa | 4

| accettato

Risposto
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...

oltre 15 anni fa | 0

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

oltre 15 anni fa | 0

Risposto
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))...

oltre 15 anni fa | 0

Risposto
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...

oltre 15 anni fa | 1

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

oltre 15 anni fa | 0

Risposto
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 ...

oltre 15 anni fa | 1

Risposto
[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...

oltre 15 anni fa | 3

Carica altro