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

8 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 ...

8 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 ...

8 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...

8 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...

8 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...

8 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...

8 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: ...

8 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...

8 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...

8 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...

8 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 ...

8 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...

8 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...

8 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 ...

8 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 ...

8 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...

8 years ago | 0

| accepted

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

8 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...

8 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...

8 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

Answered
Calling Konstants from string with name instead of index
Are you just trying to do this? [M_sig,epsopen,Emod,sigopen] = deal(A(1),A(2),A(3),A(4));

9 years ago | 0

Answered
Creating a function that solves the kepler equation
Your kepler function should output E given the values of e and M. So it should look like this in a file called kepler.m fu...

9 years ago | 0

Answered
How do I solve Kepler's equation for E using fzero?
To use fzero, you first need to form an equation with 0 on one side. So this equation: M = E - e * sin(E) becomes this e...

9 years ago | 0

| accepted

Answered
How to write a script to determine whether or not a given year is a leap-year
You are not applying the tests in the proper order. From this link: https://en.wikipedia.org/wiki/Leap_year Look at the A...

9 years ago | 1

| accepted

Answered
Create a 4D matrix with specific range values
Here is one way to do what you have asked, although I don't really know if this is the best way to go about coding the real prob...

9 years ago | 0

Load more