回答済み
Vector ODE using forward Euler method
Also your main code should look something like this: g = 9.8; mu = 0.5; [t,y]=ode45(@(t,y)rhs_1(t,y,g,mu),[0 100],[0.1; 0]); ...

約5年 前 | 1

回答済み
unique function return value of duplicate vector entry
Why can't you just use ind1 and ind2? E.g., V1_1 = V1_1(ind1); V2_1 = V2_1(ind1); V1_2 = V1_2(ind2); V2_2 = V2_2(ind2);

約5年 前 | 0

回答済み
Insignificant modification of code leads to NaN
Think about what is happening with this loop: for i = 1:num_iterates x = A*x; R(:,i) = x/norm(x); %%%% Problem Line %...

約5年 前 | 1

| 採用済み

回答済み
Skip instance of a loop with error
Something like this: try fn = x+y+z; %The function is just a representation. I am actually performing a Fi...

約5年 前 | 0

| 採用済み

回答済み
Performance of applications that are developed in MATLAB versus C++/C
Any such comparison will depend on exactly what computations are in question. A general comparison of languages probably isn't ...

約5年 前 | 4

回答済み
Numerical Integration by Matlab
Hint: You might look here: https://en.wikipedia.org/wiki/Normal_distribution Knowing that the integral of the Normal density f...

約5年 前 | 0

回答済み
Does MEX compiler (and the associated shared files) automatically ship with all MATLAB distributions of any license type?
Mex routines are not guaranteed to be compatible between different versions of MATLAB, for the very dependency reasons you alrea...

約5年 前 | 1

| 採用済み

回答済み
function call returns "index (1.2): subscripts must be either integers 1 to (2^63)-1"
You are missing a multiply operator. There is no implied multiplication in MATLAB with the 2( combination. E.g., u_1 = @(y) ...

約5年 前 | 0

回答済み
Mex, how to copy an array to output
See the solutions I posted here: https://www.mathworks.com/matlabcentral/answers/702682-with-mxmalloc-and-mxsetdoubles-mex-func...

約5年 前 | 0

| 採用済み

回答済み
With mxMalloc() and mxSetDoubles(), mex function crash matlab
You have memory leaks in your current code. E.g., tmpResult = mxMalloc(numRows*numRows*sizeof(*tmpResult)); // this memory ...

約5年 前 | 2

| 採用済み

回答済み
hi I am trying to use this code to solve RK4 equation and I keep receiving this error . what should I do?
Your implementation has several errors: Looks like you are creating i as a vector and then using that for indexing in A(i) You...

約5年 前 | 0

| 採用済み

回答済み
Filling in multidimensional array efficiently
Something like this maybe? k = 1; % your loop b = r x 1800 matrix f = whatever ch = whatever r = size(b,1)...

約5年 前 | 0

回答済み
extract out values out of loop
Make them arrays and assign to the elements. E.g., for i= 1: length(Hi) [XYZ(:,i),H(i),D(i),I(i),F(i)] = wrldmagm(Hi(i),La...

約5年 前 | 1

| 採用済み

回答済み
Projectile motion with drag. My problem is in the loop as the number of elements are not equal apparently on the left and right. Id appreciate detailed input ive been lost on this for a couple of days now
This makes AccDrag a vector: AccDrag(1,:) = [AccDragX(1) AccDragY(1) 0] So here you have a vector on the right hand side and a...

約5年 前 | 0

| 採用済み

回答済み
calling another matrix in a matrix
Don't do this! Creating numbered named variables in your code like yakit_1, yakit_2, etc. leads to downstream coding problems a...

約5年 前 | 0

回答済み
Newton Raphson Method in a for loop
You don't have the Newton-Raphson method coded correctly. You need to update the x value you use for the delta within the loop ...

約5年 前 | 0

回答済み
How to use ode45 to solve a system of two differential equation?
If you don't have the Symbolic Toolbox, here is the procedure: 1) Write your equations in matrix form: F*qdotdot + G*qdot + H*...

約5年 前 | 0

回答済み
Multiplication of large matrices
Do NOT transpose your matrix explicitly before the multiply. That will only cause a deep copy, double the memory footprint, and...

約5年 前 | 1

回答済み
[Matlab Grader] How to check if the matrix has upper triangular form?
This looks like a display issue. The numbers in the lower triangle are not exactly zero, they just display that way out to 4 dig...

約5年 前 | 0

| 採用済み

回答済み
Questions about how to plot a summation function with two variables
From the formula image, it appears you need fun( ) to create a matrix z where each element corresponds to the formula for a part...

約5年 前 | 0

| 採用済み

回答済み
How could I solve this system of ODEs?
For your case, simply start the run at time T and integrate backwards in time to t0. I.e, this is still an initial value proble...

約5年 前 | 1

回答済み
Problem when Indexing large integer arrays
This [v(end):-1:v(1)] creates an indexing array that starts at the value v(end), increments by -1, and ends with v(1). It doe...

約5年 前 | 0

| 採用済み

回答済み
dot product between two different size of matrix
Assuming everything is real and by "dot product" you aren't involving complex conjugates, simply this C = B * A';

約5年 前 | 1

回答済み
Multiply one dimension of a 3D Matrix by a vector
C = A .* reshape(B,1,1,[]); For earlier versions of MATLAB that do not have implicit expansion it would be this: C = bsxfun(@t...

約5年 前 | 0

| 採用済み

回答済み
Graph Method Root Finding
E.g., x = -1:0.01:1; % pick some x range to look for a root plot(x,x-2.^(-x)) % plot the equation grid on or fplot(@(x)x-2....

約5年 前 | 0

回答済み
covert 128 binary string into hex decimal
b = your binary digits vector d = [8 4 2 1]*reshape(b,4,[]); h = sprintf('%x',d);

約5年 前 | 3

| 採用済み

回答済み
How to use the three points A1, A2, and B0 to calculate ∠A1B0A2?
A1 = [171 422] ; A2 = [415 413] ; B0 = [277 386] ; d1 = A1-B0 ; d2 = A2-B0 ; theta = atan2( norm(cross([d1 0],[d2 0])), dot...

約5年 前 | 0

回答済み
set order of elseif
Does this do what you want: order = [1 2 3]; % or whatever for k=1:numel(order) switch order(k) case 1 if( ...

約5年 前 | 0

| 採用済み

回答済み
Fields within Cell structures.
E.g., to sort everything by mpg: [~,x] = sort([Car.mpg]); CarMpg = Car(x); To pick off only those with certain constraints, e...

約5年 前 | 0

回答済み
Convert 32 bit image to 8 bit image
I'm assuming you just need to scale things. E.g., X = your image (as a unit32?) Y = uint8( double(X) * ((2^8-1)/(2^32-1)) ); ...

約5年 前 | 1

さらに読み込む