Answered
Fastest way to find number of times a number occurs in an array?
So, you've got some potential speed problems with your posted methods. When you evaluate the expression X(:,2) repeatedly tha...

16 dagen ago | 1

| accepted

Answered
Second oder ode solution with euler methods
Rewrite your 2nd order equation as a pair of first order equations, then use Euler method on a 2-element vector. I.e., Define y...

17 dagen ago | 0

Answered
automating global definition inside multiple functions
Ugh! This is not a good code design. There are better choices. E.g., maybe use a struct with fields named for your variables, a...

17 dagen ago | 0

Answered
Calculating axial stresses of different beams
E.g., maybe using the element-wise division operator is all you need: axialforce = a scalar or vector of axial forces area = a...

17 dagen ago | 0

| accepted

Answered
how to replace elements in top third, middle third, and bottom third of matix
Your row indexing is wrong. The first n rows are 1:n which you have correct. The second n rows indexing is n more that the fir...

17 dagen ago | 1

| accepted

Answered
How to put 2 matrices together to make one matrix?
To stack them vertically, A = your 7x2 matrix B = your 3x2 matrix result = [A;B]; If you had two matrices that you wanted to...

17 dagen ago | 0

Answered
Two Dice Monte Carlo Simulation
You don't have your for-loops set up properly. You are trying to find the probability that five consecutive 7's occur in 100 ro...

18 dagen ago | 0

| accepted

Answered
Problems when comparing mwSize and mwIndex variables
A couple of observations: >> typecast(uint64(1),'uint8') ans = 1 0 0 0 0 0 0 0 >> typecast(uint64(4...

18 dagen ago | 1

| accepted

Answered
1D array to 2D array positions
n = 5; B = zeros(n,size(A,2)); B(sub2ind(size(B),n+1-A,1:size(A,2))) = 1;

19 dagen ago | 1

| accepted

Answered
How to create an array from array of numbers??
Are you sure this: speed_1=acc(2,1)*dt(2); speed_2=speed_1+acc(3,1)*dt(3); speed_3=speed_1+acc(4,1)*dt(4); speed_4=speed_1+a...

19 dagen ago | 0

Answered
For Loop Dimensions Not Consistent Horzcat
In these two lines: meanlevellist(i) = mean_SPL; meanlevellist = [meanlevellist, mean_SPL]; The first line puts mean_...

19 dagen ago | 0

Answered
How does copy-on-modify operate on structs and classes?
Question: When matlab modifies a member of a struct or class in a function, is the entire struct or class object copied, or onl...

19 dagen ago | 1

| accepted

Answered
Is there any possible way to shorten this code without using dynamic variables
cellfun might help you. E.g., this part1 = dct2(img_blocks{1,1}); : part16 = dct2(img_blocks{4,4}); could be replaced wi...

20 dagen ago | 1

| accepted

Answered
Computing time for .^(1/2) or .^(1/p)
I am unaware of any documentation on how TMW has chosen to implement their rooting/power algorithms, but it would not surprise m...

20 dagen ago | 0

Answered
I am trying to extract all the values from a for loop
You could use a counter: k = 0: % initialize outside loop : k = k + 1; time(k) = n_time(ii); That being said, i...

23 dagen ago | 0

Answered
Index exceeds matrix dimensions.
What is numel(aig)? Seems like aig doesn't have 45 elements.

23 dagen ago | 0

| accepted

Answered
Creating pointers for arrays
First, there is no way in official MATLAB that I am aware of to do what you want to do. That is, you can't have variables that ...

23 dagen ago | 0

| accepted

Answered
Unable to perform assignment because the left and right sides have a different number of elements.
I would assume this Te_(i+1)=Te_+h*fi; was meant to be this Te_(i+1) = Te_(i) + h * fi;

24 dagen ago | 1

Answered
how to define binary matrix in matlab?
If you mean that you type in the A matrix exactly as above, but want to reinterpret the decimal digits as binary digits, then ma...

24 dagen ago | 0

| accepted

Answered
how to create binary matrix in matlab
>> dec=[1;2;3;4;5]; >> bin = dec2bin(dec,4) bin = 0001 0010 0011 0100 0101 >> bin2dec(bin) ans = 1 2 ...

24 dagen ago | 0

Answered
sparse2matrix random error
You have two entries for the (2,8) spot, namely [2 8 0] and [2 8 -4]. The way you have your algorithm coded, the first one in t...

24 dagen ago | 0

Answered
How can I predict the number of runs scored?
I will get you started. You need to write a code outline for how you would do it, e.g., with commenting, and then fill in the co...

24 dagen ago | 1

Answered
How can I model the decay rate of Carbon 11 and its bar graph?
You need to account for all of the atoms in your plot. E.g., this R(i) = N - sum(f(1:i)); % <-- Wrong, you are only plotting t...

25 dagen ago | 0

| accepted

Answered
Sparse matrix ir sorting
Yes, the elements in the ir array corresponding to the same column are guaranteed to go in increasing order. The indexing is 0-...

25 dagen ago | 1

| accepted

Answered
How to loop through all rows using a for loop
I will get you started: patients = the variable that has all of the patient information for k=1:_______ <-- you fill this in ...

26 dagen ago | 0

Answered
Help with learning indexing
x is size 2x3, so the 'end' in the 2nd index position is 3. Then just do the math (3-1)/2 = 2/2 = 1 so x(2,(end-1)/2) = x(2,1)...

26 dagen ago | 0

Answered
Cross Product of an Array
M = your 3xN matrix v = your 3x1 vector result = cross(M,repmat(v,1,size(M,2)));

27 dagen ago | 0

| accepted

Answered
i need solve m*d2x/dt2 + c*dx/dt + k*x= 0 with matlab and I have encountered an error Undefined function or variable 't'. please help me
Is this code all together in one file as written above? You need to have your driver code (the code that calls ode45) first, an...

27 dagen ago | 0

Answered
How top stop for loop if value is reached
if( norm(X(c+1,:)-X(c,:)) < some_tolerance ) break; end or perhaps if( all(abs(X(c+1,:)-X(c,:))) < some_tolerance ) ...

30 dagen ago | 0

| accepted

Answered
what does this mean?
fprintf('\nIteration number = %d \n', m);

ongeveer een maand ago | 0

| accepted

Load more