Answered
Matrix Indexing
A = zeros(max(idx(:)),size(idx,1)); A(sub2ind(size(A),idx,cumsum(ones(size(idx))))) = 1

15 years ago | 2

| accepted

Answered
Programming Snafu's - My Numerical Analysis HW
I would paste them into the MATLAB editor and read the warnings. Also, try to run the functions and see what happens! They wil...

15 years ago | 0

| accepted

Answered
How do I write a good answer for MATLAB Answers?
Put a clarifying question in the "Comment on this Question" box instead of putting your question as an answer.

15 years ago | 4

Answered
How do I write a good answer for MATLAB Answers?
Ask the writer of an obvious homework question (especially when no work is shown) to: # Provide the work done so far (the code...

15 years ago | 2

Question


How do I write a good answer for MATLAB Answers?
Since the question, "How do I write a good question for MATLAB answers?" has been asked, I wondered if we could benefit from the...

15 years ago | 16 answers | 16

16

answers

Answered
How do I write a good question for MATLAB Answers?
Things I like to see in a question: # Clear explanation of the problem, current code included. If the current code doesn't wor...

15 years ago | 8

Answered
Declaring 'many' variables from work space into function workspace
Usually one should pass the variables in via the argument list. Other ways of making magic are generally frowned upon _with goo...

15 years ago | 12

Answered
Solving for log function
Use the FZERO function. What values do you have for R_1 and R_2? F = @(a) log(1/R_1).^a - log(1/R_2).^a rt = fzero(F,.1);...

15 years ago | 1

Question


What causes MATLAB to execute pasted code automatically?
Sometimes I will copy a piece of code that someone has put up in answer to a question, then paste the code into MATLAB at the co...

15 years ago | 3 answers | 2

3

answers

Answered
Which MATLAB function can remove the diagonal elements of a NxN matrix
Your example doesn't add up, as Kenneth mentioned. However, in general you could do something like this: A = [ 0 1 2 3 1 ...

15 years ago | 6

| accepted

Answered
Matrix Indexing
Another alternative: A = zeros(1,t_off(end)+1); A(t_on) = 1; A(t_off+1) = -1; A = cumsum(A(1:t_off(end)));

15 years ago | 4

| accepted

Answered
Matrix Indexing
Bruno's MCOLON function may be what you need. <http://www.mathworks.com/matlabcentral/fileexchange/29854-multiple-colon> A...

15 years ago | 1

Answered
MATLAB GUI
UITABLE was available in 2007a, for example: T = uitable('NumColumns',4,'NumRows',6,'position',[10 10 400 300]); Now to see ...

15 years ago | 0

Answered
Insert a matrix within a matrix
Assuming you meant x = [a,b;c,d]; then y = blkdiag(x,x)

15 years ago | 5

Answered
Selecting words in MATLAB
You don't say how the words are divided, or even what kind of selection is to be made. However, I will assume you have three ce...

15 years ago | 3

Answered
MATLAB GUI
Would UITABLE be what you want?

15 years ago | 0

Answered
multiplying certain parts of an 8x8 matrix
M = magic(8) S = sum(M([1 8 57 64 28 29 36 37]))

15 years ago | 2

Answered
controlling background color of selected uicontrol popup?
Things seem to work here as you wish, unless I misunderstand you. uicontrol('Style','popup','backgroundcol',[.9 .7 .3],'str...

15 years ago | 1

Answered
Yaxis invisible
I don't think there is a way of doing it directly. Here is a hackey way of getting what you want for the Y-axis. Do similar fo...

15 years ago | 1

Answered
How do I generate a vector of random integers without repeats and with j+2 constraints?
Some of your constraints would seem to be exclusive at first read. Here is an attempt at all 5: N = [1 2 3 5 6 7 8 9]; ...

15 years ago | 0

Answered
How do I find the number of character in a text file?
fid = fopen('inp.txt'); % see also fclose A = char(fread(fid,inf)).'; A = banerjee.raktim 123456789125 >> length(A) ...

15 years ago | 1

| accepted

Answered
How do I access an Invalid-named variable from an exported MAT file that MATLAB will not recognize?
Give this a try. What is the extension of the data file? X = load('01_ExportData') % May need the extension D = struct2ce...

15 years ago | 0

Answered
How do I use randperm to produce a completely new sequence (no numbers in same place)?
Or, perhaps more efficient even: function As = mix2(A) T = A(randperm(length(A))).'; As = zeros(length(A)); As(:,1) = T...

15 years ago | 1

Answered
How do I use randperm to produce a completely new sequence (no numbers in same place)?
O.k., I see I misread the requirements. You want no two elements to be equal, correct? This should work too, if A is not reall...

15 years ago | 1

Answered
How do I use randperm to produce a completely new sequence (no numbers in same place)?
You could do this with the PERMS function. A = [4 2 5 1 3]; % Sample code T = perms(A); B = randperm(size(T,1)); ...

15 years ago | 0

Answered
Binary string to character string?
userid = char(bin2dec(reshape(watermark(1:160),[],8))).' passwrd = char(bin2dec(reshape(watermark(161:320),[],8))).' str =...

15 years ago | 1

| accepted

Answered
How do you randomize numbers but not have two consecutive numbers be the same?
Use the RANDPERM function. Depending on what you want to do, pick one of these: >> A = [1 2;3 4;5 6;7 8;9 10] % Sample Data...

15 years ago | 2

Answered
Uniform distribution of N points within a sphere
Here is another solution which converts to Cartesian coordinates, though it does call the trig functions. function [x,...

15 years ago | 1

Answered
Define a function for a system using Symbolic Math Toolbox
What use could an undefined function be? If you want your function to return nothing, then: y = @(t) []; would do the t...

15 years ago | 1

Answered
Gradient and NaN
You can see what MATLAB does by looking at a plot. Look at the difference between the two figures: v = -2:0.5:2; ...

15 years ago | 0

Load more