Answered
Difference between "diff(x^2)" and "2*x"
I think the problem is you are mixing calling methods. When you pass a string to SOLVE, it looks at the string and determines t...

13 years ago | 0

| accepted

Answered
How to produce number labelling and annotations as shown below?
Here is an example of one approach. figure('units','pix','pos',[624 474 672 504]) x = 0:.01:1; plot(x,cos(x).*...

13 years ago | 0

| accepted

Answered
How to get the three maximum values from a vector
% Your string: s = '0 0 1 0 1 0 - 0 0 0 1 1 1 - 1 1 0 0 1 0 - 1 0 0 0 0 0 - 1 1 1 1 1 0'; v = sum(str2num(strrep(s,'-'...

13 years ago | 0

Answered
Numerically integrate a function f(x) over x using MATLAB where f(x) has another argument y which is a vector
Mike's solution is essentially the same, but just to show you how to do what you want in your function M-file: function...

13 years ago | 2

Answered
Error using ==> horzcat CAT arguments dimensions are not consistent. help please......
The dimensions of cA and cH or cV and cD do not match up. Look at the output of this: whos cA cH cV cD

13 years ago | 0

| accepted

Answered
get(0,'default') does not list all default properties
Here is a silly little function to get all of those defaults listed. You could modify this to produce more or less by manipulat...

13 years ago | 2

Answered
if and elseif statement with unexpected error that I cannot figure out
Look carefully at what you wrote! In the first conditional line, you check if x is greater than zero twice. In the second and ...

13 years ago | 0

| accepted

Answered
Replacing String Values By Position
You don't need to use linear indexing (STRFIND) here at all. Just use logical indexing. str = 'test rest'; str(str=='e'...

13 years ago | 2

| accepted

Answered
Problem Using User Input with Function Handle
If you are writing a function, it is probably best to dispense with input prompts and let the user pass in a function handle lik...

13 years ago | 0

| accepted

Answered
Dealing with v(end+1) when v(1) may not have been defined
v = []; v(end+1) = 5; Why would you want to do this, by the way?

13 years ago | 0

| accepted

Answered
Solve Logrithm Equation with multiple solutions
Just use numerical methods: f = @(x)(1.581/1.5)-x.*log(58./x); rt = fzero(f,.2)

13 years ago | 2

| accepted

Answered
How do I simly exit and close all the windows in R2012b?
Does: quit still work? This should get you out of MATLAB entirely. If you mean only to close all figures without quit...

13 years ago | 0

Answered
How do I get fprintf to display several matrices at once while maintaining the desired order?
fprintf('\n\n%11s%11s%11s%11s\n','x', 'y', 'r', 'theta'); fprintf(' %10.2f %10.2f %10.2f %10.2f\n', A.'); fprintf('\n\n'...

13 years ago | 0

Answered
this should be easy I have a while loop that is infinite
In MATLAB, conditionals evaluate to true if ALL values of the conditional are non-zero or true. You are repeatedly creating a v...

13 years ago | 1

| accepted

Answered
How to reshape a matrix
A = rand(2,2,2,2); B = A(:); size(B)

13 years ago | 0

Answered
Syntax error to generate Log Normal Variables
Use this instead: A = exp(randn(2,4).*0.0768+1.175) Or make a little function: Lognrand = @(S,mu,sig) exp(ran...

13 years ago | 0

| accepted

Answered
find a string in a character array
A = ['asdf';'lelr';'wkre';'pope'] idx = all(ismember(A,'lelr'),2) Now if you need linear indices rather than a logical i...

13 years ago | 1

| accepted

Answered
What is wrong with this command line?
Assuming x and n are defined before hand, there is nothing wrong with that command line. What makes you think something is wron...

13 years ago | 0

| accepted

Answered
Matlab Floating point question
In the first example, you are dividing a bunch of 1s by the sample rate. In the second, you are dividing some small numbers and...

13 years ago | 0

Answered
Get number from a string
What do you mean it didn't work. Seems to work here. So what numbers do you want? Only numbers that are after a '.' or what (...

13 years ago | 3

| accepted

Answered
iterating values of a vector under conditions
I am not quite sure what you want, but perhaps you should look at the CONTINUE keyword. If this isn't what you need, you should...

13 years ago | 1

Answered
finding a sum of a vector without using the sum(x) function
If you don't need all of the wa, you should just do a running sum. w = [1,1.2,.8,1]; x = [75, 80, 65, 78]; wa = 0; ...

13 years ago | 0

Answered
HOW TO COMPARE THE TWO DIFFRENT ARRAYS ELEMENTS IN MATLAB
It depends on what you mean by "compare elements" in your application. A = [3 4]; % An array. Let's "compare" elements....

13 years ago | 0

| accepted

Answered
To find the position of the elements which are same in vector
find(a==2)

13 years ago | 0

| accepted

Answered
How to create a password program
<http://www.mathworks.com/matlabcentral/fileexchange/24861-41-complete-gui-examples GUI_37> gives a demo of this.

13 years ago | 0

| accepted

Answered
I'm trying to create Matrices Index or subscript ?
Do *not* program that way in MATLAB! You want this: x = [1 2 3;4 5 6;7 8 9]; for ii = 1:3 y{ii} = ii*x; % N...

13 years ago | 1

| accepted

Answered
no arrows appear when plotting direction field with quiver()
The infs are messing with you. [x,y] = meshgrid(-10:1:10,-10:1:10); F = x - (1./y); [dx,dy] = gradient(F,1,1); d...

13 years ago | 1

| accepted

Answered
How can I solve the polynomial equation of delta=c1*x^4+c2*x^3+c3*x^2+c4*x+c5 ?
roots([c1 c2 c3 c4 c5-delta]) For example, given: 5 = 3*x^4 + 2*x^3 + x^2 - 5*x +3 x = roots([3 2 1 -5 3-5]) % These ...

13 years ago | 0

| accepted

Answered
Plotting points on a comet plot
According to the doc: "comet3(X,Y,Z) displays an animated comet plot of the curve through the points [X(i),Y(i),Z(i)]....

13 years ago | 0

Answered
Why won't a function handle plot?
When you make a function, you should use it like a function... syms x A = 3*x + 5*x^3; B = matlabFunction(A); x = ...

13 years ago | 1

| accepted

Load more