Answered
How do multiply all elements inside a for loop by an array
c = [2 4 6]; d = [10 20 30]; y = bsxfun(@times,c.',d) Or if you really must have a cell array: y = arrayfun(@(x) times...

15 years ago | 0

Answered
Converting a numeric array to a cell array containing vectors
mat2cell(A,[1 1],[3 3 3])

15 years ago | 0

| accepted

Answered
Matrix Filtering
Say your array is called B B([false(size(B,1),1),diff(B,[],2)==0] & B) = 0; Oops, I didn't see the diagonal condition. Hm...

15 years ago | 0

Answered
Does something similar to 'intersect' command exists for more than 2 vectors?
You could call INTERSECT multiple times: A = [1 2 3 4 5];B = [3 7 8 9 5];C = [5 0 22 3 77]; F = intersect(intersect(A,B),C)...

15 years ago | 5

| accepted

Answered
gnerates number that has digits from 1 to 9 are not repeated
Are you sure about those equations? Because I get that there is no solution... P = perms('123456789'); N = (str2num(P...

15 years ago | 0

Answered
How to replace the elements of a matrix using the conditions if,else?
IF statements *_do not_* pick out elements of an array like you are imagining that they do. When you write this: if conditio...

15 years ago | 9

| accepted

Answered
Generate a matrix which contains 70% of the data from another matrix
When the number of rows is known (and 'nice' for 70%): A = magic(10); % Lets use 10 as an example B = A(1:7,:); % Take th...

15 years ago | 1

| accepted

Answered
Draw a line
line([4 4],[0 10],'color','b') % Blue line from (4,0) to (4,10) line([0 10],[9 9],'color','r') % Red line from (0,9) to (10,...

15 years ago | 1

| accepted

Answered
function setup in fmincon
I don't have the Optimization toolbox, so I can't really test it out. However, I am pretty sure you are passing your function i...

15 years ago | 0

Answered
How do I create a set of variables from specific coordinate values in a square matrix?
% Some data to work with... A = magic(6); path = [2;4;6;1;3;5]; % The engine to get the path through A... path = [p...

15 years ago | 0

| accepted

Answered
convert logical cell array to double
If A is your array, B = [A{:}]; % Step 1. B = [B{:}] % Step 2. This will only work if each of the logical arrays in ...

15 years ago | 0

Answered
Subtracting two cell arrays, yielding a third cell array
C = cellfun(@minus,A,B,'Un',0)

15 years ago | 4

| accepted

Answered
How can I plot a string function
Is there a particular reason why you are using a string instead of an anonymous function? y = inline('x.^2+3*x+2+sin(x)'); ...

15 years ago | 0

Answered
Reading Arrow Key Input
Here is an example of how to use the arrow keys in the keypressfcn. function [] = move_fig() % move figure with arrow keys....

15 years ago | 4

| accepted

Answered
GUIDE automaticlly removes my tag from axes
When you call IMAGE, many axes properties are cleared. So after you call IMAGE, set the tag. image(rgb); axis off set(h...

15 years ago | 1

| accepted

Answered
I have a vector and want to compute the average value
First of all, don't name a variable mean! This will mess up your use of the MATLAB function MEAN. This produces a plot similar...

15 years ago | 2

| accepted

Answered
How do I replace the zeros in a matrix with another integer, or with a pos or neg infinity?
To replace only the diagonal of a N-by-N matrix with infinity, do: A(1:N+1:N^2) = inf; % or A(1:N+1:end)... If you want t...

15 years ago | 9

| accepted

Answered
What's the best way to create a vector with a repeating and diminutive sequence?
N = 6; A = cumsum(tril(ones(N,'single'))); A = A(A>0).'; If memory is a concern, this will conserve it: L = (N^2+N)/2;...

15 years ago | 0

| accepted

Answered
Get derivatives from noisy data
Numerical differentiation with noisy data is notoriously unreliable. Have a look at <http://math.lanl.gov/Research/Publications...

15 years ago | 0

| accepted

Answered
Save an array to a txt file allowing choosing path name and file name
See the help for <http://www.mathworks.com/help/techdoc/ref/uiputfile.html UIPUTFILE> and friends. UIPUTFILE allows you to sele...

15 years ago | 0

| accepted

Answered
error using questdlg
The proper use of QUESTDLG is: ButtonName = questdlg(Question, Title, Btn1, Btn2, Btn3, DEFAULT) Only (up to) three custom bu...

15 years ago | 1

| accepted

Answered
Extracting and using the values of variables in workspace in a loop
clear all x = 1:10; y = 4; a = whos; eval(a(1).name) eval(a(2).name) But what is it that you are really wanting to ...

15 years ago | 0

Answered
Mouse Motion and Object Handle
This is adapted from one of my <http://www.mathworks.com/matlabcentral/fileexchange/24861-41-complete-gui-examples GUI examples>...

15 years ago | 0

| accepted

Answered
Plot already exisitng graphs onto one graph
I assume that you have two saved MATLAB figures, firstpane.fig and secondpane.fig, each with one axes object. fh = figure; ...

15 years ago | 1

| accepted

Answered
Single-Colon Indexing for Struct Variables
Just to make sure I understand what you did, does this example correctly model your issue? my_data(3)=struct('x',[],'y',[]); ...

15 years ago | 1

| accepted

Answered
How do I get help on homework questions on MATLAB Answers?
MATLAB Answers is a place you can get help from the user community on specific MATLAB questions. It is not intended as a place t...

15 years ago | 21

| accepted

Answered
Creating large gui, setting callbacks
I would probably use a muli-line editbox instead of having many editboexes. For example: U = uicontrol('style','edit',... ...

15 years ago | 1

Answered
Best way to write some equations and generate a graph
Is n a scalar, or is it supposed to be in a loop? If it is loop index, what is the range? x = {(t2(n)-t1(n)) + (t4(n)-t3(n))...

15 years ago | 0

Answered
Vector Defined by Two Points
[(x1-x2) (y1-y2)]

15 years ago | 2

Answered
Plot different colors while using loops.
You can make a cell array of your chosen colors, then: C = {'k','b','r','g','y',[.5 .6 .7],[.8 .2 .6]} % Cell array of colro...

15 years ago | 17

| accepted

Load more