Answered
Imag, real function error
It could be that you have inadvertently created variables with the name "real" or "imag" that are shadowing the functions real a...

9 years ago | 0

Answered
generating random values from another matrix with a random value in rows only
Is something like this what you want? Randomly distributed values from X but staying in same column? X = whatever rows ...

9 years ago | 0

| accepted

Answered
Write a MATLAB script and user defined function that solves the following orbital equation of motion using ode45
Your code is not even remotely close to what it needs to be for this. In the first place, since you have a 2nd order ODE in 3-s...

9 years ago | 0

| accepted

Answered
Newton's Method for a polynomial equation
You need to create function handles for your functions. As written, MATLAB thinks you are trying to evaluate the functions at a...

9 years ago | 0

| accepted

Answered
Derivative in function handle
E.g., if you want function handles you could get at them with the symbolic toolbox >> syms x >> f = @(x) x + log(x) f...

9 years ago | 1

Answered
how to extract another matrix out of a big matrix
v = [420,422,425]; B = A(ismember(A(:,1),v),:);

9 years ago | 1

| accepted

Answered
Pick 3 lotto code
Here is the instruction: _"... that generates 3 random numbers 1000000 times ..."_ And here is your code: N=1000000 ...

9 years ago | 0

Answered
Predict the value of pi through the following program and compare with real pi using 2*[(2*n)^2/((2*n)^2-1)]
Just looking at the terms you are summing: S = S + (2*t)^2 / ((2*t)^2-1) The limit as t -> infinity of the part you are ...

9 years ago | 2

Answered
A simple "bug" in finding an element in an array using find()?
Not a bug. Just the way floating point arithmetic works. E.g., 0.1 cannot be represented exactly in IEEE double precision, so ...

9 years ago | 0

Answered
t=a:h:b;
An outline of the loop: s = whatever a = whatever b = whatever h = whatever y = zeros(size(t)); y(1) = s...

9 years ago | 0

Answered
Undefined function 'eq' for input arguments of type 'cell'.
You could change your test to this if you want an exact match: if isequal(x{i},'Apples') x(i) is a cell, whereas x{i} is...

9 years ago | 0

Answered
How do I use code in C in matlab?
You could start with the mex doc: <https://www.mathworks.com/help/matlab/call-mex-files-1.html> There are several examples...

9 years ago | 0

| accepted

Answered
how to convert a p code to .m file with Matlab student version 2016
p code is encrypted. The author typically uses p code because he/she doesn't want the user to be able to recover the original m...

9 years ago | 1

| accepted

Answered
Segmentation fault when recoving data from a C code through Mex programming
I haven't tried to run, or even compile, your code. But based on a very quick visual scan it appears to me that this line: ...

9 years ago | 0

Answered
Very Difficult MATLAB program I am trying to write.
If you just want to plot a rotated moon phase, here is an approach using the "fill" command. % ang = angle to rotate counte...

9 years ago | 3

Answered
Return by reference from coder.ceval - access to a C array?
I'm not familiar with what you can do to tweak the Coder, but for sure you can't get at the memory you are trying to in the abov...

9 years ago | 0

Answered
Is there a way to do signed 16 bit integer math?
_"... In standard C programming ..."_ Well, sort of. Signed integer overflow behavior is not really defined in the C languag...

9 years ago | 1

| accepted

Answered
For the second part of the question, I keep on getting the following error. I am assuming this is because I need to somehow create a cell inside the cell corresponding to Out? What would be the simplest way of doing this?
You've still got that j-loop too complicated. Use my outline above. Using your vector=[] approach, it would be: vector ...

9 years ago | 0

| accepted

Answered
how to convert The binary number floating point to decimal notation, as example,(1.10101010 * 2^1001 ) is equal to 852
You could start with this FEX submission by Toby Driscoll: https://www.mathworks.com/matlabcentral/fileexchange/25326-ieee-75...

9 years ago | 0

Answered
matlab second order nonlinear ode
Since it is a 2nd order ODE, first define a 2-element vector, let's call it y just like the examples in the ode45 doc, that matc...

9 years ago | 1

| accepted

Answered
creating matrix w.r.t. rows number of another matrix
E.g., a method using a cell array u = unique(col_row(:,1)); n = numel(u); result = cell(max(u),1); for k=1:n ...

9 years ago | 1

| accepted

Answered
how do i use the in-built inv function to calculate a matrix inverse and then calculate A-1A and AA-1.
The comment character % needs to be at the beginning of the comments. So these lines Inverse = %calculate the inverse of a ...

9 years ago | 0

Answered
am calling a print function: cdata=print(filetosave,'-djpeg','-r0'); which succeeds in writing the file but then throws an error: One or more output arguments not assigned during call to "varargout". Perhaps you can help?
According to the doc here: https://www.mathworks.com/help/matlab/ref/print.html?s_tid=doc_ta The only form of calling prin...

9 years ago | 0

| accepted

Answered
Place zero in an empty matrix within cell array?
x(emptyCells) = {-1};

9 years ago | 0

| accepted

Answered
Can Matlab Factorial a Large Number?
You could use one of these FEX submissions by John D'Errico: https://www.mathworks.com/matlabcentral/fileexchange/22725-varia...

9 years ago | 0

| accepted

Answered
Issue: Matrix Dimensions Must Agree
Use element-wise operator ./ (with the dot) instead of the matrix operator / E.g., Volume1=n*R*T1./P; Volume2=n*R*T2...

9 years ago | 0

Answered
How to keep only 1st row of every 450 rows of data
x = your full data imported from Excel result = x(1:450:end,:); Subset every 450 rows starting with the first

9 years ago | 0

| accepted

Answered
How do I multiply multidimensional array by a vector?
First, whenever you are working with multi-dimensional matrices and need to access 2D slices of them for matrix manipulation, it...

9 years ago | 0

Answered
Randperm a completely different set of numbers each loop
If you mean the numbers can be the same but have to be in different spots, I suppose you could rotate the matching numbers to ge...

9 years ago | 0

Load more