Answered
Help saving a vector to the workspace that is output from a function.
How are you calling the function? To get the variables in the workspace make sure you are capturing two outputs. E.g., call ...

11 years ago | 0

Answered
Question about loop ranges
The obvious guess would be that some of your results are exactly 0 when you get beyond 2000, so the method of cropping the zero ...

11 years ago | 0

Answered
Help saving the output of a for loop within a function into a vector.
There are vectorized ways to do this (without a loop), but to answer your question directly you could add the index numout onto ...

11 years ago | 0

| accepted

Answered
Calling C/C++ code from MATLAB - example
You can start with the mex examples in the doc: http://www.mathworks.com/help/matlab/ref/mex.html

11 years ago | 0

Answered
How to split a complex vector(H) into equal parts using for loop ?
You could do it with simple indexing k = The set you want to extract (1 = 1st set, 2 = 2nd set, etc) V = H((1:12)+(k-1)*...

11 years ago | 0

| accepted

Answered
Evalaute a string left to right
If you will accept evaluating this all at once, here is one way to do it (only works if the rhs is legit MATLAB syntax, which yo...

11 years ago | 2

Answered
How do I solve this system of coupled differential equations?
Eliminate the 2nd derivative by introducing another variable (i.e., increasing your states). Then you will have a set of 1st ord...

11 years ago | 1

| accepted

Answered
Fibonacci sequence, slightly different.
Looks like your indexing into seq is not quite right. Try this: seq(k)=seq(k-1)+begin;

11 years ago | 0

| accepted

Answered
Creating new vector wich adds previous value with for loop
b = cumsum(a); To fix your explicit loop, don't set b = 0 at each iteration, and use proper indexing into the vectors. E.g....

11 years ago | 2

Answered
i dont quite understand the maclaurium series expansion coding
You can look at this link for a lot of information on series expansions: http://en.wikipedia.org/wiki/Taylor_series In par...

11 years ago | 1

| accepted

Answered
Asking user for input, returning a matrix
You are close. Just a few syntax things to clear up. input('prompt1') uses the explicit string 'prompt1' as the prompt text. ...

11 years ago | 0

Answered
question about addressing matrix elements
Yes. The colon operator when used with three values is starting_value:step:ending_value e.g., 5:-1:2 ans = ...

11 years ago | 0

Answered
Creating a game board for 15-puzzle
You can use reshape to get the random integers into the matrix shape you want. E.g., tiles = reshape(randperm(16)-1,4,4) ...

11 years ago | 1

| accepted

Answered
Can I assign a single value to multiple elements of a cell array without a loop
You almost had the syntax right: myArray(find(cellfun(@isempty,myArray))) = {0} Or you can just use logical indexing and...

11 years ago | 2

| accepted

Answered
Need 3rd dimension indicies for calling values.
m = size(N2s,1); n = size(N2s,2); [~,x] = max(N2s,[],3); % 3rd dimension indexes of the max locations y = (1:m*n)' + ...

11 years ago | 1

| accepted

Answered
creating 30 digits numbers and finding sum
>> "Any idea on how to approach the sum now?" Well, if you had two 30-digit numbers written on a piece of paper, how would yo...

11 years ago | 1

Answered
Sparse linear system of equations
Are you just asking how to construct B_N? E.g., B_N = spdiags(repmat([-1 2 -1],N,1),[-1 0 1],N,N); A_N = speye(N) -...

11 years ago | 0

| accepted

Answered
How to add matrices dimension by dimension without using a loop?
Don't know if this will be faster than your repmat code, but try this: J = bsxfun(@minus,reshape(ldp,1,1,i2,j2,j3),reshape(...

11 years ago | 1

| accepted

Answered
Accessing elements in a multilevel structure
The key to the following is that many operations (e.g., Patients.Lesion) return a comma separated list result, so one uses the [...

11 years ago | 2

| accepted

Answered
How do I create an auto named variable?
Before you do this you should read this link: http://www.mathworks.com/matlabcentral/answers/57445-faq-how-can-i-create-varia...

11 years ago | 2

Answered
Using the text command, how can I display a string genrated from sprintf and a string in one line?
text(mean(xlim),max(ylim),sprintf('p = %4d',p_num)) If you need the leading 0's printed then text(mean(xlim),max(ylim)...

11 years ago | 0

Answered
Help switching variables in a vector using a for loop
You made a good start, but need to fill out the insides of the for-loop. Part d.iii is instructing you to have one line insid...

11 years ago | 0

Answered
Use matrix c\c++ API with row-based indexing
You could transpose it after loading the mat file. Or you could call MATLAB to transpose it for you prior to saving the variable...

11 years ago | 1

| accepted

Answered
Convert binary column vector to decimal
If I understand your question, A is a numeric 52 x 15 matrix consisting of 1's and 0's. For that case you can use: B = bin2...

11 years ago | 3

Answered
For loop code not working right?
You have used the variable p9 as your loop index AND as the accumulation variable. Use a different variable name for the loop in...

11 years ago | 1

Answered
Sending big sparse matrix to C through mex: matlab crashing
Sparse matrices are not stored in memory the same way that full matrices are. In particular, the 0's are not physically stored. ...

11 years ago | 2

| accepted

Answered
mex File not Recognized
As Jan has already pointed out, "The specified module could not be found" message means that the SMAT_matlabcall.mexw32 file its...

11 years ago | 0

Answered
Count number of matrix elements in a given vector
M = 30 x j matrix of random ordered numbers 1:30 C = 30 x 1 "correct" ordering of 1:30 N = sum(bsxfun(@eq,M,C)); % Numbe...

11 years ago | 1

| accepted

Answered
How can I insert vectors created in a for loop in a matrix?
E.g., wpvector = 0:0.5:5; % Create a vector the same size as the loop range k = 0; % Initialize the index into this vec...

11 years ago | 1

Answered
Solving a vector system
HINT: What do you get when you add the two equations together? And what do you get when you subtract the two equations? Just do ...

11 years ago | 0

Load more