Answered
Allocating values in a 3D array using nested for loops
Since this is apparently a homework assignment, I will get you started. Since the requirement is to use nested loops, I assume t...

11 years ago | 5

| accepted

Answered
mex difference between mwPointer and pointer in Fortran90
An mwPointer is simply a macro that translates into a signed integer (32-bit or 64-bit) in Fortran. It is used to store memory a...

11 years ago | 0

| accepted

Answered
how to normalize a matrix?????
Assuming values are positive, e.g., M = your matrix N = bsxfun(@rdivide,M,max(M)); % Normalized (scaled) matrix by colum...

11 years ago | 2

Answered
Pick out rows one by one from a vector to use as initial values in differential equation?
Do you mean something like this? initial_conditions_matrix = (a 100 x 4 matrix) m = size(initial_conditions,1); for k...

11 years ago | 1

Answered
Error using - Matrix dimensions must agree. HELP
The best course of action usually is to get into the debugger and stop your code at the line that is generating the error, and t...

11 years ago | 0

Answered
&& in if statement returning error
It appears you have a vector involved in your test, e.g., d_0_ij(1:sz_dist_obs(1,1),1) == distance_obs(1,1) As written, ...

11 years ago | 0

Answered
Hot to display a variable from a row ?
Looks like a typo, missing ' in your code. Try this: disp(['m34= ' num2str(m34(j))]);

11 years ago | 2

Answered
mixed programming technology of Matlab and C/C++
Have you looked at the details in the doc? E.g., here: http://www.mathworks.com/help/matlab/programming-interfaces-for-c-c-fo...

12 years ago | 1

Answered
Bug in matlab R2012b version
Others have already adequately answered your question. But to help you gain a better understanding of this I will point you to a...

12 years ago | 3

Answered
Sum(X) = 1 but Sum(X)==1 produces logical 0
Note that when a number is exactly an integer, and you are only printing one scalar value, MATLAB prints it without any trailing...

12 years ago | 0

Answered
Replacing all values except NaN with column number
E.g., y = floor(rand(6,3)*100); y(2:6,3) = nan; % test data z = repmat(1:size(y,2),size(y,1),1); z(isnan(y)) = nan...

12 years ago | 0

| accepted

Answered
How to find number of significant figures in a decimal number?
This is not necessarily trivial to do reliably. In the first place, 31.456 is not representable in IEEE double exactly, so those...

12 years ago | 5

| accepted

Answered
Question about mexfunction link to dll
I usually explicitly put the name of the lib file directly on the mex command. E.g., try something like this assuming the lib fi...

12 years ago | 1

| accepted

Answered
Error in using mldivide in mex
You don't need to create plhs[0] explicitly since the mexCallMATLAB call will do that for you. Also, you don't need to explicitl...

12 years ago | 0

| accepted

Answered
Is there a way to create all m files with already filled in some predetermined lines that are needed for every file like clear all; close all; author name etc?
Have a template file sitting out there (e.g. mytemplate.m) that has a function outline & comments (author etc) already filled in...

12 years ago | 0

Answered
ind2sub doesn't work
The typical use of ind2sub in your case is to request two outputs: [I J] = ind2sub(size(tmp), maxInd) I = 3 J...

12 years ago | 2

Answered
Remove a specific dimension
If you *know* the first dimension is always a singleton at some point in your calculation, you can use reshape instead of squeez...

12 years ago | 8

| accepted

Answered
please help,....how to fix this one,....??? Input argument "D" is undefined. Error in ==> MSA at 2 m=D.m;n=D.n;Ni=zeros(12,12,m);S=zeros(6*n);Pf=S(:,1);Q=zeros(12,m);Qfi=Q;Ei=Q;
The error is saying that you called the MSA function without supplying any arguments. E.g., if you did something like this: ...

12 years ago | 0

Answered
Filter out nonzero number in array of n*2 dimension.
If I understand your question, you want to delete the rows with non-zero entries in both columns, e.g., idx = sum(A~=0,2)==...

12 years ago | 1

Answered
How to add matrices in a function with varying input arguments
Do you mean simply adding up all of the varargin individual inputs, like this? if( nargin ) matrix_sum = varargin{1}...

12 years ago | 1

| accepted

Answered
When to use mex files?
First thing to do is use the profiler and let MATLAB tell you where it is spending most of the time. Then you can decide on what...

12 years ago | 0

| accepted

Answered
Mean Function with Matrix
There *are* five values listed. Each of the five values in the 2nd row is multiplied by the factor 1.0e-3. It is MATLAB's way of...

12 years ago | 2

| accepted

Answered
increase vector with mex function
I don't know about the CUDA stuff, but you have a basic mismatch of types in your C code. E.g., v = ones(100,1); The abo...

12 years ago | 0

| accepted

Answered
Simple mex function help
You have defined x and y in mexFunction to be *pointers* to double, not double. But your xtimes10 routine is expecting double, n...

12 years ago | 1

| accepted

Answered
How to create a vector out of arrays
I am guessing that Header is a cell array of strings, even though you have typed it in your post using parentheses ( ) instead o...

12 years ago | 0

Answered
addressing elements in a cell aray of cells
Not sure what your actual desired outcome is, but this syntax works to replace the 'eeg2' with 'eeg3': new{1,2}(2) = {'eeg3...

12 years ago | 0

| accepted

Answered
While Loop Problem Displaying NaN
If you check this link, you will see that the series you are using only converges for abs(x) <= 1 and x not equal to -1: http...

12 years ago | 0

Answered
ERROR USING VERTCAT HELP PLEASE
It is unclear what you are trying to do with the loop. P is a vector [100 200 ... 1000], so the for loop indexing i=1:P doesn't ...

12 years ago | 1

| accepted

Answered
Using .' instead of ' for transpose
For complex matrices, see Azzi's answer. You are doing a little extra work for the conjugate part. For real matrices, I don't...

12 years ago | 0

Answered
find the minimum of a matrix
[val idx] = min(X(:,j)); idx will be the row number.

12 years ago | 3

| accepted

Load more