Réponse apportée
Connect four diagonal win condition
board((r+fours),(c+fours)) is not the diagonal going from board(r,c) to board(r+3,c+3). It is the 2D sub-matrix containing ever...

plus de 5 ans il y a | 0

Réponse apportée
Why did Matlab crash when I run mexw64 file ?
In Fortran, NEVER pass literal integers to the API routines because you cannot guarantee the integers will be the correct size n...

plus de 5 ans il y a | 0

| A accepté

Réponse apportée
Extracting elements common to rows and columns in a matrix
M = your matrix result = M([3,5],4:5) The [3,5] syntax is simply a vector with the indexes specified in any order. They don't...

plus de 5 ans il y a | 0

| A accepté

Réponse apportée
Peobelms about matrix dimensions
Take a look at this term: exp(-1*E./T.). Looks like you have too many periods in this part of the calculation. Try this exp(...

plus de 5 ans il y a | 0

Réponse apportée
ode45 For Three Functions
You made a good start, but you need to solve these differential equations simultaneously. That will mean you need to work with ...

plus de 5 ans il y a | 0

Réponse apportée
Bitwise "AND" logic operator not giving accurate results!!!
MATLAB is case sensitive. powersof2 and powersOf2 are different variables. Use the same case for both.

plus de 5 ans il y a | 1

Réponse apportée
Convert C++ to Mex
See the input( ) function for getting the inputs from the user. Then see the fprintf( ) function for displaying formatted outpu...

plus de 5 ans il y a | 0

Réponse apportée
Compiling MEX files that use IMSL Numerical Libraries
Something like this should get you close: mwPointer plhs(*), prhs(*) mwPointer, external :: mxGetM, mxGetN, mxGetPr, mxCreateD...

plus de 5 ans il y a | 1

| A accepté

Réponse apportée
the use of eye command?
eye(M,N) creates an MxN matrix with 1's along the main diagonal (from the upper left corner down towards lower right) and 0's ev...

plus de 5 ans il y a | 0

| A accepté

Réponse apportée
Euler, Runge Kutta, and ODE45
You could use a switch control block to run the method selected. https://www.mathworks.com/help/matlab/ref/switch.html?s_tid=sr...

plus de 5 ans il y a | 0

| A accepté

Réponse apportée
How to fix time step ?
Your function handles are functions of t, so you need to be passing in t, not n. E.g., if t(n)<5 speed0(n) = spe...

plus de 5 ans il y a | 1

| A accepté

Réponse apportée
I'm not sure why my code is working. It is for a projectile rocket that has water, so need to take into account water thrust and drag to find the distance travelled. The code is below:
Some quick observations: This t=t+i*dt; should be this t(i+1) = t(i) + dt; Your indexing appears to be incorrect also. You...

plus de 5 ans il y a | 0

Réponse apportée
Subscript indices must either be real positive integers or logicals.
This line produces indexes of zeros: for a = zeros(1, Nmax-1) I think you meant this instead: g = zeros(1, Nmax); for a = 1:...

plus de 5 ans il y a | 0

| A accepté

Réponse apportée
sort an array without using the command sort
Instead of using find, you could just have the min( ) function return the index to you. And then delete that element. [v1(...

plus de 5 ans il y a | 0

| A accepté

Réponse apportée
Reshape does not Use the Columns I Want
For your posted example, simply [x(:,1:2);x(:,3:4)] But this begs the question, what is your real problem and what sizes can x...

plus de 5 ans il y a | 0

| A accepté

Réponse apportée
Basic math operations on contents of a cell array
I suppose only TMW could give you their reasons for not implementing numeric operations on cell arrays. Maybe they simply didn'...

plus de 5 ans il y a | 1

Réponse apportée
Triangular pulse with function handle t(@)
If you must use a one-liner function handle, the general form could be this: f = @(t) (t >= 0).*(t < pulseDuration/2).*(express...

plus de 5 ans il y a | 0

| A accepté

Réponse apportée
Output to an array or matrix
Colon operator. A = 1:5;

plus de 5 ans il y a | 0

Réponse apportée
What are all the possible combinations given the restrictions?
Buy any item in January and any other item in the other month. All combinations are valid and within the $8 budget so essential...

plus de 5 ans il y a | 0

| A accepté

Réponse apportée
Function takes as input two nonempty matrices A and B and returns the product AB
This is a matrix multiply, so you need to keep the rows and columns of the inputs separately. E.g., [NRowsA,NColsA] = size(A);...

plus de 5 ans il y a | 0

Réponse apportée
Roll a die until n consecutive rolls have the same value
You made a good start, but it might help to change your inner while loop exit condition to be exactly what you are looking for ....

plus de 5 ans il y a | 0

| A accepté

Réponse apportée
Solve function give 2 answers when there should be 1.
For a generic orbit problem, i.e. an ellipse, there are always going to be two places on the orbit path with the same r value (e...

plus de 5 ans il y a | 0

| A accepté

Réponse apportée
MatLab While loop indexing?
Add a counter to your loop. Initialize the counter to 0 and add 1 to it within the loop. E.g., counter = 0; % other stuff w...

plus de 5 ans il y a | 0

| A accepté

Réponse apportée
Extracting a submatrix based on conditions on first columns of a big matrix
BigMatrix = your big matrix BigMatrix1 = BigMatrix(:,1); % 1st column x = BigMatrix1 > 527 & BigMatrix1 < 580; % logical index...

plus de 5 ans il y a | 1

| A accepté

Réponse apportée
Can someone help me figure out what is wrong with my function c1 = ult_trid(m,b) ??
d is a 4x1 vector and you are trying to access the d(4,4) element, hence the error.

presque 6 ans il y a | 0

Réponse apportée
Question about numerical integration for cos vs cosd
By hand: int cosd(theta) = int cos(theta*pi/180) = sin(theta*pi/180)*180/pi Integrated from 0 to 15 degrees: sin(15*pi/180)...

presque 6 ans il y a | 2

| A accepté

Réponse apportée
Error: File: d3.m Line: 7 Column: 10 Invalid use of operator.
Looks like you are missing some variable names and some matching parentheses in this line: scatter((:,1)),(:,2)),'o')

presque 6 ans il y a | 0

Réponse apportée
Please help me write the f function in matlab
I would assume from the equation image that the exp( ) stuff maybe should be outside of the sin( ) stuff. E.g., f = 2.*x.*sin(...

presque 6 ans il y a | 0

Réponse apportée
How to create multiple matrices with different sizes without a loop?
You will either need to use loops, or hide the loops behind a function call (e.g., arrayfun): result = arrayfun(@(x)randi([0 x]...

presque 6 ans il y a | 0

| A accepté

Réponse apportée
Inserting a column in a matrix before adding it to another matrix in a loop
C = [A,[B1;B2;B3]];

presque 6 ans il y a | 0

Charger plus