回答済み
ODE45 generates undesired matrix of NaN entries
This is often an initial condition issue with the specific DE's involved. In your code, you have icond(2) = 0 icond(3) = ((F/...

3ヶ月 前 | 0

回答済み
How can I transfer the size of the array to mexFunction
Try this (caveat, untested). Don't pass in the row size of the matrix ... just pass in the matrix only. Let the code figure ou...

3ヶ月 前 | 0

| 採用済み

回答済み
Preallocating a Matrix(For loop, Vectorization)?
In these lines: Y4=repmat(A,N,1); Y4 = cell2mat(arrayfun(@(i) A^i, (1:N)', 'Uni', false) The first line assigns something to ...

3ヶ月 前 | 1

| 採用済み

回答済み
how can i use several loops
MATLAB will do all of the loops in the order it encounters them. So for the k=1 iteration it will do the i=1:nx loop in its enti...

3ヶ月 前 | 0

| 採用済み

回答済み
Call function and save results
Maybe just display the results: disp(results); Or loop differently: for k = 1:size(results,1) disp(results(k,:)) end

3ヶ月 前 | 0

| 採用済み

回答済み
How combine two cell arrays matlab
E = cellfun(@(x,y)[x y],C,D,'uni',false);

4ヶ月 前 | 3

| 採用済み

回答済み
How do i do Matrix reordering (cutting into blocks)?
It's not exactly clear what the actual size of your matrix is (maybe you could clarify), but for what you have posted maybe this...

4ヶ月 前 | 0

| 採用済み

回答済み
Can i delete part of a cell array based on a condition?
E.g., >> C = {'CGU','UUU','UAG','GGU'} C = 1×4 cell array {'CGU'} {'UUU'} {'UAG'} {'GGU'} >> X = {'UAA','UAG...

4ヶ月 前 | 0

| 採用済み

回答済み
Why am I receiving this error "Index in position 2 exceeds array bounds (must not exceed 1)."
When you load into a variable, the data loads into a struct. The fieldnames of that struct are the variables in the mat file. S...

4ヶ月 前 | 1

回答済み
Index error when using function
We need to see more of your code to be sure, but you likely have a variable named either f or dx that is shadowing a function of...

4ヶ月 前 | 0

回答済み
No-copy read object property from mex c++
There is no official API method to do this with the C API. You have to resort to unofficial hacks. E.g., see this FEX submission...

4ヶ月 前 | 0

回答済み
How to make an array that the elements are matrix
Maybe use a cell array? E.g., graph.frontier = {[3x3],[3x3],[3x3],[3x3]}; You can then get at the matrices with curly braces,...

4ヶ月 前 | 0

回答済み
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...

4ヶ月 前 | 1

| 採用済み

回答済み
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...

4ヶ月 前 | 0

回答済み
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...

4ヶ月 前 | 0

回答済み
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...

4ヶ月 前 | 0

| 採用済み

回答済み
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...

4ヶ月 前 | 1

| 採用済み

回答済み
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...

4ヶ月 前 | 0

回答済み
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...

4ヶ月 前 | 0

| 採用済み

回答済み
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...

4ヶ月 前 | 1

| 採用済み

回答済み
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;

4ヶ月 前 | 1

| 採用済み

回答済み
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...

4ヶ月 前 | 0

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

4ヶ月 前 | 0

回答済み
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...

4ヶ月 前 | 1

| 採用済み

回答済み
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...

4ヶ月 前 | 1

| 採用済み

回答済み
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...

4ヶ月 前 | 0

回答済み
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...

4ヶ月 前 | 0

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

4ヶ月 前 | 0

| 採用済み

回答済み
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 ...

4ヶ月 前 | 0

| 採用済み

回答済み
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;

4ヶ月 前 | 1

Load more