Answered
Plot a 100x100 grid of 1's and 0's
Another option: b = your binary matrix spy(b);

6 years ago | 0

Answered
“Dimensions of arrays being concatenated are not consistent”
TYpe this at the command line: dbstop if error then run your code. When the error occurs the code will pause with all current ...

6 years ago | 0

Answered
ODE45 randomly returns vector of length 1.
Try clearing your variables before you run the script. It could be that you are inadvertently using a variable from a previous i...

6 years ago | 0

Answered
Solving System of 1st Order ODEs with Euler's method
The easiest way is to treat your y as 2-element column vectors instead of scalars. E.g., % function file function [x, y] = od...

6 years ago | 1

| accepted

Answered
Cell Array, Example From Manual
The variable C is only a 2D variable having two dimensions. You have requested indexing into a third dimension with that last...

6 years ago | 0

| accepted

Answered
sum every n columns, element by element
m = your matrix n = number of columns to sum squeeze(sum(reshape(m,size(m,1),n,[]),2))

6 years ago | 1

| accepted

Answered
How do I get rid of a dimension of length 0 in a multi-dimensional array?
A variable that has a 0 dimension is an empty variable ... there is no data in it to reshape. You need to backtrack in your cod...

6 years ago | 0

| accepted

Answered
ode euler - explicit method
Add this after each figure statement hold on

6 years ago | 0

| accepted

Answered
Monte Carlo Simulation - pair of dice roll
You are supposed to count the number of rolls it takes to get boxcars, not the number of boxcars you get in N rolls. So for eac...

6 years ago | 0

| accepted

Answered
How to concatenate two time arrays with the same time step?
Ttotal = [t1,t1(end)+1+t2];

6 years ago | 1

| accepted

Answered
plot graph using Tsiolkovsky’s rocket equations.
This Speed(1) = ... needs to be this Speed(i) = ... and this ... v_e*m(i)/m(i-1) ... should be this ... Time_step*v_e*dmd...

6 years ago | 0

| accepted

Answered
How to solve coupled differential equations with more than one dependent variable and only one independent variable?
This dy(3)= -3*y(1)*y(3)+2*y(2)^2+y(4); should be this dy(3)= -3*y(1)*y(3)+2*y(2)^2-y(4); % changed +y(4) to -y(4) Also, if ...

6 years ago | 0

| accepted

Answered
About mex function problem
This code is incorrect: int nVars,nSteps,lhs_dims[2]; : plhs[0] = mxCreateNumericArray(2,lhs_dims,mxDOUBLE_CLASS,...

6 years ago | 0

Answered
How to graph a complex system of ODEs?
You have three 1st order equations, so you need a 3-element state vector for this. To keep the same nomenclature as the MATLAB ...

6 years ago | 0

Question


Why is the new "half" data type an opaque class?
The good news: The new half precision data type was introduced in R2019b. Graphics cards have been using this for quite some t...

6 years ago | 1 answer | 6

1

answer

Answered
How to convert half-precision number into hexadecimal representation?
I don't have R2019b installed so I don't know how half precision numbers are stored, but can you use typecast: h = your half pr...

6 years ago | 3

| accepted

Answered
Issue with the cross product of my r and v vectors.
You need to make your r and v matrices of 3-element column vectors, not one long string of number all in a row. That means putt...

6 years ago | 0

| accepted

Answered
Deleting Row and Column
Q = P(1:end-2,1:end-2);

6 years ago | 0

Answered
Custom Euler's Method for Second Order ODE
Your derivative matrix is wrong. It should be this (the -5 and -1000 are switched): A = [0,1;-1000,-5];

6 years ago | 1

| accepted

Answered
I am 2nd year university student and unfortunalty due to corona virus im strugging with Matlab code. Can i email someone on here who has time to help me with a few questions on a car crash study.
This is essentially a pendulum problem with two forces acting on it instead of just one, gravity acting vertically down and cras...

6 years ago | 0

Answered
Override subsasgn of MATLABs double?
Overriding subasgn for a native class like double is a very bad idea, because it affects everything, not just the code that you ...

6 years ago | 2

Answered
Need help solivng euler method code
This n = numel(y0); needs to be this instead n = numel(x); % number of independent variable values Then you need to initiali...

6 years ago | 0

Answered
How to plot simple function
Error message says to check for mismatched delimiters. So this y=(1/(1+(25*x^2)); should be this with one fewer paren: y=1./(...

6 years ago | 0

Answered
A function calculating the value of expression (sin(x) - x)*x^(-3).
So, for small values of x your code looks correct to me (although the N=200 is WAY WAY OVERKILL ... you don't need nearly this m...

6 years ago | 0

Answered
Index in position 1 is invalid. Array indices must be positive integers or logical values.
What are the values in Fb and Tb? You can do this at the command line: dbstop if error Then run your code. When the error occ...

6 years ago | 1

Answered
Most Efficient Way to Construct the Matrices to Extract the Lower and Upper Triangle from a Vectorized Matrix
Here is a mex routine that generates the sparse double matrices mL and mU directly, so no wasted memory in creating them. Seems...

6 years ago | 2

| accepted

Answered
How do you substitute x(1),x(2),x(3) in place of kp,ki and l respectively?
To keep your equation the same, e.g., y1 = @(kp,ki,l) ((1/10^(l + 1)*ki*kp*l*sin((pi*l)/2))/(kp + (ki*kp*cos((pi*l)/2))/10^l) -...

6 years ago | 0

Answered
what is the number in a position in an array?
Indexing: m(2)

6 years ago | 0

| accepted

Answered
Dont why i keep getting reshape error anytime i run this.
This line reshape = reshape(encrypt,50,50); %50x50 shadows the MATLAB reshape( ) function with your own variable called reshap...

6 years ago | 0

Load more