Community Profile

# Jon

Last seen: Today Active since 2013

#### Content Feed

View by

How to solve for N sets of 2 equations and 2 unknowns using a for loop?
This is one approach using nested functions to pass additional paramaters, see https://www.mathworks.com/help/optim/ug/passing-e...

6 days ago | 0

| accepted

Convert from linear to log scale and back again
I think you can get what you want using MATLAB's semilogx function

7 days ago | 0

Is there a way to find the mean of every other number in a vector and compare it to every other number in another vector?
I'm not sure if I am clear on what you are trying to do but from your description I would do something like this: red = [2 4 3 ...

7 days ago | 1

Trying to combine multiple square matrices diagonally into a combined larger matrix
You can use MATLAB's blkdiag function for this so in your case T = blkdiag(A,B,C)

7 days ago | 0

intersect() returns unplausible values
I think you may be misunderstanding the usage of MATLAB's intersect function. It finds the set intersection (elements in common)...

7 days ago | 0

| accepted

how can i get value of y
It looks like you are trying to solve for the root of a nonlinear function. You can use MATLAB's fzero to do this. Type doc fzer...

7 days ago | 1

If point x belongs to vertices of rectangle?
You could define a 4 by 2 array, corners, with the corner values (first column x values, second column y values) then do somethi...

8 days ago | 0

| accepted

How to solve this error : "index out of bounds because numel(U)=1"
With your definition of U, U has only one element. Note you first assign a scalar (one element) variable u=1, then you assign U ...

8 days ago | 0

| accepted

3 Excel COLUMNS x,y,z imported into work space as vectors, z is a function of x,y how do i get the data into a 2d lookup table
Here is an example MATLAB script that you could run to assign the necessary variables in your base workspace before running yo...

8 days ago | 0

| accepted

How to adjust axes created using plot
use the ylim command for example g = @(x) sin(x)/x fplot(g, [-10, 10]) title('The result of fplot') ylim([-2,2])

12 days ago | 1

How to read an image & convert it into an array and vice versa
You can use MATLAB's imread and imwrite functions for this. On the command line you can type doc imread to get documentation fo...

12 days ago | 0

How to select corresponding rows of a table based on selected rows of one column?
T = readtable('sadegh.geo_cod.xlsx'); % sort the rows of table in descending order of areas Tsrt = sortrows(T,'Area1','desce...

13 days ago | 0

| accepted

Remove successive rows from a table where a specific column value is duplicated
If I am understanding correctly I think this will do what you are asking T = readtable('Metingen-data-2021-11-17 10_48_18.csv')...

13 days ago | 0

| accepted

Using a string in an if statement to print data from excel.
put single or double quotes around yes if view_data == 'yes' and also around no in the following line

13 days ago | 0

Why do I have "Warning: Imaginary parts of complex X and/or Y arguments ignored."
Most likely you are trying to raise a negative value to a fractional power, for example x^0.5 or x^0.4 where x is negative. Thi...

14 days ago | 0

Simulink build a loop and define intial conditions
In general you should be able to run your simulation iteratively by starting the simulation programatically using the MATLAB sim...

14 days ago | 0

How to plot stair like this??
I think this does what you want and is nice and simple X = [95 0;onlyPlot] stairs(flip(X(:,2)),flip(X(:,1)),'-o')

15 days ago | 0

| accepted

Cant get for loop to run
It looks like you define f to be a scalar at the top of your script. So it doesn't make sense to iterate through values of f(n) ...

15 days ago | 0

| accepted

How do you take the absolute value of only the complex number?
x = -0.0115+0.0059i xnew = real(x) + abs(imag(x))*i

18 days ago | 0

How do I set a starting point in a find function
If you know you wanted to start the search at a known row and column index you could use iStart = 2 jStart = 3 [a,b] = find(A...

18 days ago | 0

| accepted

Ignore zero values when searching for minimum value in column of matrix
idl = cANALY(:,1)>0 % use logical indexing [tnValueAnaly, tnRowAnaly] = min(cANALY(idl,1));

18 days ago | 0

| accepted

Animated 2D ball trajectory with images
You can plot a filled circle (or an approximation of one) by plotting filled polygons using the fill command. For example to pl...

19 days ago | 0

| accepted

How to import data from excel and multiply a specific extracted column?
Hi, The problem is that you are reading the variables into tables, not vectors. You can't multiply a scalar value times a tabl...

20 days ago | 0

| accepted

MATLAB returns a wrong value of determinant.
There will always be some tolerance in numerical methods compared with exact solutions. 3.88858e-15 is considered very small, an...

20 days ago | 0

Find sequence of numbers in vector
Rather than using strings you can check a condition involving the numerical value of the elements in a, something like if a(k) ...

21 days ago | 0

How do I get the average of a signal over every certain time duration (simulink)?
So I'm assuming you are looking for an output signal that has a sampling period of 0.1 seconds, which gives the average value of...

22 days ago | 0

| accepted

intersect between the second column of cell array A (for all rows) and the first column of cell array B (for all rows)
The problem is that A{:,2} and B{:,1} are not returning arrays but instead multiple answers. So somthing like this: >> A = {1,2...

22 days ago | 0

Replace array elements with strings
In the example code below I show how to do it with 4 names, but you can expand it to however many names you have. names = {'Pis...

25 days ago | 0

| accepted

Output of loop is 2x1 vector
If you want to store the results of each loop in a 2 by numSteps matrix you can do this numSteps= 10000; %k steps c = 0.000001...

25 days ago | 0

| accepted