Respondida
New to matlab, need help with problem..
Good start. Thank you for posting your code. Some help: - Have the top value of your loop be 300, not 299 - Have the Tot...

más de 8 años hace | 0

Respondida
Can one run a matlab script from the command line and pass arguments to it **without making it into a function**?
You could have your script use the getenv( ) function to retrieve all of those environment variables (as strings). Or have your...

más de 8 años hace | 0

Respondida
how can I create help product for my function in matlab?
Put all of your help text in comments at the top of the file. E.g., here is a file called mycube.m % MYCUBE Calculates the...

más de 8 años hace | 0

Respondida
Repeating a row vector in MATLAB until it reaches a specified length.
result = k(mod(0:numel(j)-1,numel(k))+1);

más de 8 años hace | 0

Respondida
Result as a vector
Use element-wise divide operator with the "dot", ./ vx1 = (0.287*Tx1)./Px1;

más de 8 años hace | 0

| aceptada

Respondida
find the position of en element if you have the increment
You need to be careful how you search for this element. Because of the way the colon operator works with floating point fractio...

más de 8 años hace | 0

Respondida
How to concatenate matrices using for loop?
If x is a cell array, and you simply want all of them, then result = cell2mat(x); or if you want them stacked vertically...

más de 8 años hace | 0

| aceptada

Respondida
How to find the corresponding vector?
Dist = zeros(1,n); Distx = zeros(n,numel(x)); % <-- ADDED, allocate for saved x vectors for k=1:n xp = randperm(...

más de 8 años hace | 1

| aceptada

Respondida
Need to modify function handle output when a function is within the function handle
E.g., you could use another function handle to pick off the element you wanted. sim4end = @(x)x(4,end) Then your result ...

más de 8 años hace | 0

| aceptada

Respondida
Modify element in a matrix, row vector
rowvector(rowvector>=0 & rowvector<=500) = 0;

más de 8 años hace | 0

Respondida
How to sum the results of a loop?
E.g., for generic x s = sub2ind(size(d),x(1:end-1),x(2:end)); Dsum = sum(d(s)); If you always wanted to sum the super...

más de 8 años hace | 0

Respondida
How can I find all possible combiantions of 3 numbers in a 6 number array using a for loop?
Assuming your instructions are to use nested loops and that you need to pull exactly three elements, the looping is fairly strai...

más de 8 años hace | 0

Respondida
How do I generate a uniform random number from a 2d matrix to form a 3d matrix
E.g., later versions of MATLAB: A = whatever; f1 = 0.8; f2 = 1.2; n = 5000; B = A .* (f1 + rand([size(A) n])*(f...

más de 8 años hace | 0

Respondida
how to place zeros instead of blanks in array
If you really mean blank spaces, then e.g. B(B==' ') = '0';

más de 8 años hace | 0

| aceptada

Respondida
How to find the number in a vector that is most common and get the index
result = find(a==mode(a)); If there is more than one number that ties for "most", the above will only find the first such o...

más de 8 años hace | 0

Respondida
Acessing fields of a structure
Assuming your struct is multi-element, with each element having a username and a password. One way, which first converts the us...

más de 8 años hace | 0

Respondida
About preallocating for speed
This depends on what the size and class of the matrix returned by build_matrix( ) is. E.g., suppose it returns an MxN double ma...

más de 8 años hace | 0

| aceptada

Respondida
Is it possible to create a sub-array without using additional memory on Matlab?
What you are attempting to do creates an invalid mxArray. That is, the data pointers of an mxArray *must* be known by the MATLA...

más de 8 años hace | 1

Respondida
Why i am getting Error using * Inner matrix dimensions must agree.
Type the following at the command line: dbstop if error Then run your code. When you encounter the error, the code will...

más de 8 años hace | 0

Respondida
MATLAB using .m file in preference to .mexw64
Either: - Put the .mexw64 file in the same directory as the associated .m file Or: - Make sure the directory where the ...

más de 8 años hace | 0

| aceptada

Respondida
A sparse matrix vector multiplication in C mex programming
Here is the bare bones C code for this. Most of the code consists of argument checking etc. The actual computation part of the...

más de 8 años hace | 2

| aceptada

Respondida
How to access array element from vector of its entries
One way: c = num2cell(v); result = A(sub2ind(size(A),c{:}));

más de 8 años hace | 0

| aceptada

Respondida
solving odes (resiscted 3 body problem)
Building matrices with [ ] can be picky when it comes to spaces. E.g., >> [1;5-3;4] ans = 1 2 4...

más de 8 años hace | 0

| aceptada

Respondida
Array multiplication along certain dimension?
Another way: B = sum(bsxfun(@times,A,reshape(V,1,1,1,numel(V))),4); Or in later versions of MATLAB: B = sum(A.*resh...

más de 8 años hace | 0

Respondida
Adding zeros to a matrix to match the dimensions of two matrices.
Another way: newA = zeros(size(B)); newA(1:size(A,1),1:size(A,2)) = A;

más de 8 años hace | 2

Respondida
Is it possible to do an in-place mxCalloc at a specific address, like "placement new"?
You cannot attach memory allocated from native C/C++ functions to an mxArray. Period. It will result in an assert seg fault. ...

más de 8 años hace | 1

Respondida
splitting matrix using while loop
Hint, if x is your data then x(1:100) will be the first part, x(101:200) will be the second part. Etc.

más de 8 años hace | 0

Respondida
Dice roll, how to write if statement for not 6 or 1?
E.g., if all(ismember(x,2:5))

más de 8 años hace | 2

Respondida
what is the problem of this function code?
The reason you are getting the error is because you change the size of the grades variable within the loop, so the last index(es...

más de 8 años hace | 0

| aceptada

Respondida
how can i delete the extracted rows from the original matrix ?
x = M(:,15)<6; % Remember the logical indexes of the rows Tand= M(x, :); % this is the extracted one with 400*15 dimension...

más de 8 años hace | 0

| aceptada

Cargar más