Respondida
Working with an equation and variables from user.
You can construct a function handle as follows: f = str2func(['@(x,y)' str1]); You can then use this function handle to evalua...

casi 5 años hace | 0

| aceptada

Respondida
A matlab code that allows the user to put inputs as
See the input( ) function for getting input from the user: https://www.mathworks.com/help/matlab/ref/input.html?searchHighlight...

casi 5 años hace | 0

Respondida
Using a for loop determine how many months it would take to acquire £500,000.
You don't know the number of iterations it will take, so that is your clue that a for-loop is not appropriate. Use a while-loop...

casi 5 años hace | 0

Respondida
User-defined function to perform Cramer's Rule
You made a good start. A and b should be inputs to your function, not outputs. Similarly, issquare is an internal test and sol...

casi 5 años hace | 0

Respondida
Equation expansion using Symbolic Toolbox
This has been discussed on this forum before, and there is no easy solution to getting the Symbolic Toolbox to deal with non-com...

casi 5 años hace | 0

Respondida
How to populate a cell array from another cell array?
It is not clear what elements you need extracted. But you can use regular indexing with cell arrays. E.g., result = m_test(1,...

casi 5 años hace | 0

| aceptada

Respondida
How to compile mex file
You are simply supposed to type (or copy & paste) that text into the command line at the > prompt. Just be in the directory whe...

casi 5 años hace | 0

Respondida
Functions inputs/outputs
This is the signature of your Plot3D function: function Plot3D(Array32 ,str) As you can see, it doesn't return any outputs. B...

casi 5 años hace | 1

| aceptada

Respondida
Solve the system of equations using Cramer's Rule x+y+z=9,2x+5y+7z=52,.2x+y-z=0.
Original question: Solve the system of equations using Cramer's Rule x+y+z=9,2x+5y+7z=52,.2x+y-z=0. i want code for it And ...

casi 5 años hace | 0

| aceptada

Respondida
How to transpose a cell array blockwise?
E.g., brute force approach result = reshape([D{1};D{2};D{3}],[],1);

casi 5 años hace | 1

| aceptada

Respondida
Classical orbital elements Vectors
Use the norm( ) function instead of mag( ). E.g., norm(v) instead of mag(v). Calculate evec before you calculate e. Your evec...

casi 5 años hace | 0

| aceptada

Respondida
Why `mxGetField` could not be assigned to output of c mex?
The reason this crashes is because you have created a copy of an mxArray variable without telling the MATLAB Memory Manager that...

alrededor de 5 años hace | 0

| aceptada

Respondida
Replace the diagonal with NaN in this 5x5 matrix
You could use linear indexing for the diagonal. E.g., assuming x is square you could add this line to your function: y(1:size(...

alrededor de 5 años hace | 2

Respondida
precision problem ? why ans for 10 ^ 5 * 0.0633 is 6.3299e+03
Normal floating point arithmetic effects. See this link: https://www.mathworks.com/matlabcentral/answers/57444-faq-why-is-0-3-...

alrededor de 5 años hace | 0

Respondida
Getting a random list of numbers on a very specific interval
Generate the list according to the range width of valid values, then adjust the results. E.g., r = rand(10000,1)*80; ix = r >...

alrededor de 5 años hace | 0

| aceptada

Respondida
error using multiplication, incorrect dimensions
There are vectors in those equations, so maybe you just need to use element-wise operations: k1 = ((b.*(p+theta-n2).*c0+I.*(a.*...

alrededor de 5 años hace | 0

Respondida
Numeric integration for systems of vector equations
I haven't looked through your code, but from your description it sounds like you are making a fundamental error in your state sp...

alrededor de 5 años hace | 0

| aceptada

Respondida
Preserving numerical symmetry in large nxn matrix
Here is a mex routine to do this calculation. It relies on inputting the diagonal matrix as a full vector of the diagonal eleme...

alrededor de 5 años hace | 0

| aceptada

Respondida
Fast matrix multiplication with diagonal matrices
Here is a mex routine to do this calculation. It relies on inputting the diagonal matrices as full vectors of the diagonal elem...

alrededor de 5 años hace | 1

| aceptada

Respondida
How to divide a vector randomly in 3 groups?
Based on my current understanding, maybe this rejection method might do what you want. Again, since there are only three groups...

alrededor de 5 años hace | 1

| aceptada

Respondida
Inverse a cell of matrices
Yes, you can do something like this: T1inv = cellfun(@inv,T1,'uni',false); That being said, this begs the question of what you...

alrededor de 5 años hace | 0

Respondida
Sorting two simple matrices
Use the 2nd output argument of the sort( ) function, which has the indexing. E.g., [Asorted,ix] = sort(A); Bsorted = B(ix);

alrededor de 5 años hace | 1

| aceptada

Respondida
Preserving numerical symmetry in large nxn matrix
Why do you think L should be symmetric? E.g., (1) L = D^-1 * W * D (2) L^T = (D^-1 * W * D)^T = D^T * W^T * (D^-1)^T = D * W ...

alrededor de 5 años hace | 0

Respondida
Error in ODE45, must return a column vector
Just make your function handle return a column vector by using ; instead of , to separate the elements. E.g., ode = @(Qhat,X) [...

alrededor de 5 años hace | 0

Respondida
How to Solve 13 ODEs simultaneously by ode45
Your c0 has only 12 elements. It needs to have 13 elements.

alrededor de 5 años hace | 0

Respondida
How to generate double pendulum using ode 45
You have a 4-element state vector, so your derivative needs to be a 4-element state vector. E.g., dxdt=[theta1dot;theta2dot;th...

alrededor de 5 años hace | 0

Respondida
Help with arrays please
I'm not sure what the question is. Just enter the text as shown to create the 2x2 matrix A: A = [-10 -9; -8 6]; ...

alrededor de 5 años hace | 0

Respondida
How to calculate mean to an equal area in Matlab?
n = 3; % or whatever number of samples you need, must be divisible into size of data time_average = mean(reshape(time_data,n,[]...

alrededor de 5 años hace | 0

| aceptada

Respondida
What code should I use to be able to solve these MatLab questions?
Hint #1: Here is sample syntax to use to create a 2x4 matrix Q = [1 2 3 4; 5 6 7 8] Hint #2: See the following function for s...

alrededor de 5 años hace | 0

Respondida
How to divide a vector randomly in 3 groups?
Maybe a simple loop: n = numel(A); n10 = floor(0.10*n)-1; n80 = floor(0.80*n); for k=1:3 k1 = randi(n-n10); k2 = k...

alrededor de 5 años hace | 0

Cargar más