Risposto
Multiplication chart In MATLAB
You don't need R. Just multiply ii*jj. E.g., fprintf('%g ', ii*jj) There are also ways to generate this table without any fo...

oltre 5 anni fa | 0

Risposto
Is it possible to pass functions as arguments to C++ MEX functions?
Just quickly skimming the MATLAB C++ API doc, it looks like you can do this using the matlab::engine::MATLABEngine::feval interf...

oltre 5 anni fa | 0

| accettato

Risposto
Program that sums as many numbers as user wants
An outline of the code could be: total = 0; while( true ) % insert code here to get a number from the user % insert ...

oltre 5 anni fa | 0

| accettato

Risposto
issue using indices...maybe?
You are doing a numeric itegration to generate the plotting points. Numeric integration will build up errors over time, so the ...

oltre 5 anni fa | 0

| accettato

Risposto
Finding the intersect between 2 lines
If you want the intersection of two lines and you have the equations of the lines, just use backslash. E.g., if you have these ...

oltre 5 anni fa | 0

| accettato

Risposto
Create a concatenated matrix in matlab
Change this HMC_Kh = [HMC_Kh; H]; to this HMC_Kh(i,1:numel(H)) = H; There were two problems with your current code. The numb...

oltre 5 anni fa | 1

Risposto
Sign of imaginary value changes after converting to array
Here is what I get: >> a = 2 + 1j; >> b = 1 + 3j; >> z1 = a*b z1 = -1.0000 + 7.0000i >> z2 = b*conj(b) z2 = 10 >>...

oltre 5 anni fa | 1

Risposto
How can I plot the function y = e^(-2x^2) * cos(4pi*x - 1.5)?
Pick a range for x. E.g., x = 0:0.01:2; y = exp(-2.*x.^2) .* cos(4.*pi.*x - 1.5); plot(x,y)

oltre 5 anni fa | 0

| accettato

Risposto
Where in my code using runge- kutta four step method did I make a mistake?
Type the following at the command line: edit rk4singlestep.m Then copy your code into that file and save it.

oltre 5 anni fa | 0

| accettato

Risposto
Projectile motion without drag
You don't define the Vx(k) value before using it, hence the error. Since your Vx values don't change you can fix this error by ...

oltre 5 anni fa | 1

| accettato

Risposto
Define x,y,z and evaluate them.
You can define variables simply by typical assignment. E.g., x=5; y=4; etc. You can use * for multiply and ^ for exponentiat...

oltre 5 anni fa | 0

Risposto
Fortran MEX returns only some elements of output array.
The problem isn't using allocatable variables ... MATLAB mex functions can handle that just fine. The problem is that you are u...

oltre 5 anni fa | 1

| accettato

Risposto
System of ODEs with interdependent variables
I would advise writing a derivative function for this. E.g., dydt = myderivative(t,y,gna,gk,gl,Vna,Vk,Vl,I) V = y(1); n = y(...

oltre 5 anni fa | 0

| accettato

Risposto
Outlet Limit: water depth and flow rate
You are being asked to write a function that takes H and Q as inputs, and outputs the diameter D. So the function outline would...

oltre 5 anni fa | 0

Risposto
writing out a quadratic
Use the element-wise operators that include the "dot" (such as .^ instead of just ^), and use the multiply operator * between th...

oltre 5 anni fa | 0

Risposto
How can I select three random sample of a matrix with minimum separation between samples?
A rejection method is straightforward. Simply make your selections in a forever loop until you get something that works. The a...

oltre 5 anni fa | 1

| accettato

Risposto
Cell to matrix under new variable
Do not do this! You are taking a method of storing your data that is easy to maintain and access (e.g., in a loop) and proposin...

oltre 5 anni fa | 0

Risposto
Adding 2 matrices together in matlab, got errors instead
result = [a,b];

oltre 5 anni fa | 1

| accettato

Risposto
Reduce size of multidimensional array
One way using summing: result = squeeze(sum(your_array,3));

oltre 5 anni fa | 2

| accettato

Risposto
Euler's code for multiple ODEs
You have two states, so your result should have two values per step. So this code: y = zeros (1,N); % Initialize the Y vec...

oltre 5 anni fa | 1

Risposto
Runge-Kutta 4th Order on a 2nd Order ODE
All of your derivatives should be with respect to the independent variable x. In the context of your problem, dy/dz does not ma...

oltre 5 anni fa | 1

| accettato

Risposto
Something wrong with quat2angle() function?
I agree that this looks like a bug, and you should submit a bug report to TMW for this. I ran it in R2017a and R2020a and both ...

oltre 5 anni fa | 0

| accettato

Risposto
want to solve (d^2 y)/(dx^2 )+dy/dx-6y=0 using 4th order Runge-Kutta method with y(0) = 3 and y’(0) = 1
Change your function handle from this f = @(x) (dy^2)/(dx^2 )+dy/dx-6*y; to this f = @(x,y) [y(2);-y(2)+6*y(1)]; The last pa...

oltre 5 anni fa | 1

| accettato

Risposto
How to use Bisection Program to locate Roots of given function
If the derivative depended only on the time t then your strategy for finding the maximum/minimum points would be a good one. Ju...

oltre 5 anni fa | 0

Risposto
ODE45, ODEfunc question
What you might want to do is pass a function handle for this. E.g., in your calling code create the function handle: C1 = what...

oltre 5 anni fa | 1

| accettato

Risposto
Runge-kutta 4th order Method Help
All of your F's need to be functions that operate on the current full states. E.g., take this one F_C1 = (xc*yc*((C1.*R1)./(R1...

oltre 5 anni fa | 0

| accettato

Risposto
Difference/usage of mwIndex, mwSignedIndex and mwSize in mex C-code
MATLAB provides multiple libraries that mex code links to. There can be both 32-bit and 64-bit versions of functions in the var...

oltre 5 anni fa | 1

| accettato

Risposto
Matrix index is out of range for deletion.
You should step through this with the debugger to see what is going on. I.e., click to the left of a line and then run your cod...

oltre 5 anni fa | 0

Risposto
How to stack k copies of a matrix
B = repmat(A,1,1,k);

oltre 5 anni fa | 0

Risposto
how can i find the co-ordinates of intersections of two lines?
Suppose you have two line equations: 2x + 3y = 1 3x - 5y = 11 Then you can form the matrix A and the right hand side vector b...

oltre 5 anni fa | 0

Carica altro