Respondida
Is there any way to speed up matrix multiplication if I only need a subset of the entries?
Just out of curiosity I coded up a mex routine to compare. The mex routine simply does naive dot products between rows & columns...

más de 9 años hace | 1

Respondida
Newton Raphon's Method - Help
I don't know why you would use all of the symbolic stuff inside your function (as opposed to just hard coding the derivative), b...

más de 9 años hace | 1

Respondida
Bisection Method Not Working
It is not clear to me that your initial guesses are even bracketing your desired tof. So there will be no hope that your bisecti...

más de 9 años hace | 0

Respondida
i have 186 brain mri 2d slices (256*215) i want to stack them into 3d array (256*215*186) ?
Type the following at the command line: dbstop if error Then run your code. When the error is encountered the code will ...

más de 9 años hace | 0

Respondida
How do I create a function that accepts a 3 element vector as input, but returns scalar values?
If I understand you correctly, here is an outline of such a function (in a file called sort3.m): % Filename sort3.m func...

más de 9 años hace | 0

| aceptada

Respondida
accessing double arrays in a multidimensional array
e.g., A = your 256x256x1056 array B = mean(A,3); % <-- average of A over the 3rd dimension C = mean(A(1:50,1:50,:),3...

más de 9 años hace | 0

| aceptada

Respondida
fast initialization of cell array of strings mex
So, sounds like you have a single array of char data in your C routine, with a second int array that contains start/stop locatio...

más de 9 años hace | 1

| aceptada

Respondida
Why am I unable to plot all values in a for loop?
Rather than a loop, can you just do this? T = 0: 0.01: 0.2; V_1 = Voc_close + (V_0 - Voc_close).*exp((-T./2)./(Rt_close....

más de 9 años hace | 0

Respondida
How can I compare two strings with different size/length in MatLab?
E.g., assuming you just want to count total number of characters that are exactly the same: s1 = a string s2 = another s...

más de 9 años hace | 0

| aceptada

Respondida
A way to extract values based on the value of their neighbor?
This picks off the items with a 1 to the left (in columns 1 or 3) for your 4-column example: G = [g(:,1:2);g(:,3:4)]; G ...

más de 9 años hace | 0

Respondida
How to write a function equation in matlab?
Here is a function assuming single values for x1 and x2, which would be stored in the vector x: % Assumes numel(c)==size(A,...

más de 9 años hace | 0

| aceptada

Respondida
Complex roots equality problem
R2016b: >> rts=roots([16 -32 116 0 -100]) rts = 0.904997916303652 + 2.626226923351172i 0.904997916303652 - 2.6...

más de 9 años hace | 0

| aceptada

Respondida
Problem in ode15s, undefined function for input arguments of type double
Try giving a function handle to oce15s instead of a character string file name. E.g., [t, q_i_1]=ode15s(@leading_vehicle, ...

más de 9 años hace | 1

Respondida
How can I set the arrays dimensions?
You can't "freeze" the size of native variables in MATLAB. They are free to change size at any time. (You could make an OOP clas...

más de 9 años hace | 1

Respondida
Exercise: Add 3 to just the odd elements of x=[2 5 1 6]
Create z = x and then modify the elements of z directly using the indexes contained in y. E.g., z = x; z(y) = z(y) + 3; ...

más de 9 años hace | 0

| aceptada

Respondida
How can i add a prime counting function to this?
n = zeros(1,N); n(p) = 1; c = cumsum(n);

más de 9 años hace | 1

| aceptada

Respondida
Divide a cell arrays with a part of another cell array
Try this: C = num2cell(bsxfun(@rdivide,cell2mat(A),cell2mat(B(1,2:end)))); Note that B{1,2:end} using the curly brac...

más de 9 años hace | 0

| aceptada

Respondida
Raise elements of cell arrays in the power of 2
Like this? A = 2x100 cell array of scalars A2 = mat2cell(cellfun(@(x)x.^2,A),ones(1,2),ones(1,100)); SIDE NOTE: Yo...

más de 9 años hace | 0

| aceptada

Respondida
How to define and call a function in the same script
Does it have to be a script? Can you simply wrap your script in a dummy function name? Then you could simply attach your other ...

más de 9 años hace | 1

Respondida
Subtract from a cell array of vectors a vector
Does this do what you want? A = 2x100 cell array of scalars B = 2x1 cell array of scalars C = mat2cell(bsxfun(@minu...

más de 9 años hace | 0

Respondida
How do I resize an mxArray
You are missing a step. After you do the mxRealloc, you need to set this new pointer into the mxArray. E.g., a = mxRealloc...

más de 9 años hace | 1

| aceptada

Respondida
how to convert negative integers(that are not between -127 and 0) to binary in matlab?
What range are they in? E.g., for a 16-bit range: bitstream = dec2bin(typecast(int16(b),'uint16')); You've got numbers o...

más de 9 años hace | 0

Respondida
I got "Conversion to cell from double is not possible." on this line ERROR(:,i)=error; ,,,,any help please?!
"error" is the name of an intrinsic MATLAB function. Do you have a variable called "error" also?

más de 9 años hace | 0

Respondida
How to apply a function to an specific column of all variables?
Try this: eval([myvars{i} ' = data']);

más de 9 años hace | 0

| aceptada

Respondida
Struct as input to mex file
You are passing in a 1x1 struct, so the only valid index inside a mex routine is 0 since the indexing is 0-based. So change thi...

más de 9 años hace | 0

| aceptada

Respondida
I get "In an assignment A(:) = B, the number of elements in A and B must be the same." error when I execute the following code.
Do you need to index the sin(y) as as sin(y(n)) in this line: x(n+1)=(log(x(n)^2)-sin(y(n))+(3*x(n)/2));

más de 9 años hace | 1

| aceptada

Respondida
bsxfun with AND condition
Assuming q{x,y} and compare# are different sizes and need bsxfun, just & the two separate calculations: result = bsxfun(@lt...

más de 9 años hace | 0

| aceptada

Respondida
How do I fix my code to produce ones along the reverse diagonal?
Yet another way using linear indexing: I = zeros(n); I(n:n-1:end-1) = 1;

más de 9 años hace | 3

Respondida
Which of these two assignments is more efficient
Another method to try that might be faster for your application: %% (3) or is this faster c_mem(1:end-1)=c_mem(2:end); ...

más de 9 años hace | 0

Cargar más