Answered

Find the equality of each value in the vector and cell array

% better test data A = {1;[];1;[1 4];3}; B = [1;4;10;4;3]; temp = zeros(length(B),1); for i=1:length(B) % isequal handl...

Find the equality of each value in the vector and cell array

% better test data A = {1;[];1;[1 4];3}; B = [1;4;10;4;3]; temp = zeros(length(B),1); for i=1:length(B) % isequal handl...

19 days ago | 0

| accepted

Answered

Overwriting information in a cell array

Braces access cell contents, allowing you to update (in this case, appending to the end and hoping it's a compatible shape) Bra...

Overwriting information in a cell array

Braces access cell contents, allowing you to update (in this case, appending to the end and hoping it's a compatible shape) Bra...

19 days ago | 0

| accepted

Answered

Simulate single sine wave

Without the noisy signal? See sin documentation. With the signal (i.e. fitting to it), check out the answer to this question

Simulate single sine wave

Without the noisy signal? See sin documentation. With the signal (i.e. fitting to it), check out the answer to this question

19 days ago | 0

Answered

How can I fix "Index in position 2 exceeds array bounds" in for loop/ if statements?

Okay, I believe this code is equivalent to what you have, cleaner and without the error % pre-allocate with cell arrays of [] ...

How can I fix "Index in position 2 exceeds array bounds" in for loop/ if statements?

Okay, I believe this code is equivalent to what you have, cleaner and without the error % pre-allocate with cell arrays of [] ...

23 days ago | 0

| accepted

Answered

This is function to help

Whether this can be vectorized is really a question about SD. It's possible it works on columns straight off: Val = SD(VImage,Q...

This is function to help

Whether this can be vectorized is really a question about SD. It's possible it works on columns straight off: Val = SD(VImage,Q...

23 days ago | 0

Answered

What is missing from MATLAB #2 - the next decade edition

Ok, this is pretty minor, but: For common functions that return values as the first output and indices as the second, it would ...

What is missing from MATLAB #2 - the next decade edition

Ok, this is pretty minor, but: For common functions that return values as the first output and indices as the second, it would ...

23 days ago | 0

Answered

Indices of 2D array

data =[ 2 5 0 15 12 7 4 8 19 14 20 25 18 13 40 ]; reshaped_data = reshape(data,3...

Indices of 2D array

data =[ 2 5 0 15 12 7 4 8 19 14 20 25 18 13 40 ]; reshaped_data = reshape(data,3...

24 days ago | 1

| accepted

Answered

Potting graphs with if else and for

If it throws an error, please include that information. If that error is what I'm seeing: Error using plot. Vectors must be th...

Potting graphs with if else and for

If it throws an error, please include that information. If that error is what I'm seeing: Error using plot. Vectors must be th...

24 days ago | 0

| accepted

Answered

extracting information from tall timetable using a loop

Looks like you could do everything with groupsummary, assuming you can figure out how to define the bins G = groupsummary(TT,'T...

extracting information from tall timetable using a loop

Looks like you could do everything with groupsummary, assuming you can figure out how to define the bins G = groupsummary(TT,'T...

28 days ago | 0

| accepted

Answered

Trying to create a matrix by nesting a for loop in another for loop

No need for loops, except if effectiveness doesn't accept arrays % nx1 NTU = (2.5:0.1:3.5).'; for i=1:length(NTU) eff(i)...

Trying to create a matrix by nesting a for loop in another for loop

No need for loops, except if effectiveness doesn't accept arrays % nx1 NTU = (2.5:0.1:3.5).'; for i=1:length(NTU) eff(i)...

28 days ago | 0

| accepted

Answered

How to plot phase and amplitude spectrum after doing fft?

See this example for in angle documentation

How to plot phase and amplitude spectrum after doing fft?

See this example for in angle documentation

28 days ago | 0

Answered

Convert from cell of a table to an array

It gets tricky with different variable types and widths, but hopefully this helps. Worst case, you build up the new table elemen...

Convert from cell of a table to an array

It gets tricky with different variable types and widths, but hopefully this helps. Worst case, you build up the new table elemen...

29 days ago | 0

| accepted

Answered

CREATE HISTOGRAMM WITH A SPECIFIC NUMBER OF CLUSTERS IN X AXIS

histogram: x = randn(1000,1); nbins = 5; h = histogram(x,nbins)

CREATE HISTOGRAMM WITH A SPECIFIC NUMBER OF CLUSTERS IN X AXIS

histogram: x = randn(1000,1); nbins = 5; h = histogram(x,nbins)

1 month ago | 0

Answered

Z must be a matrix, not scalar or vector - SURF

struct array is a terrible way to store this data. Does this do it? tbl = struct2table(b); surf(tbl.temperature,tbl.humidity,t...

Z must be a matrix, not scalar or vector - SURF

struct array is a terrible way to store this data. Does this do it? tbl = struct2table(b); surf(tbl.temperature,tbl.humidity,t...

1 month ago | 0

| accepted

Answered

Projectile motion using while loop Time of flight

Basically, the issue is that you are only updating a small portion of the relevant variables each time step. A few questions Is...

Projectile motion using while loop Time of flight

Basically, the issue is that you are only updating a small portion of the relevant variables each time step. A few questions Is...

1 month ago | 0

| accepted

Answered

plotting a function correctly

x=[-2:0.1:2]; y = exp(-x)-x; plot(x,y)

plotting a function correctly

x=[-2:0.1:2]; y = exp(-x)-x; plot(x,y)

1 month ago | 0

| accepted

Answered

what is the code for bin histogram of fraction to the bin

You can specify the histogram edges like this, with the height of the bars normalized to %: x = randn(1000,1); edges = 25:5:50...

what is the code for bin histogram of fraction to the bin

You can specify the histogram edges like this, with the height of the bars normalized to %: x = randn(1000,1); edges = 25:5:50...

1 month ago | 0

Answered

Plotting Phase angle in Matlab

First off, "load" is for Matlab files, not raw text. Check out textscan. If your code isn't error-ing, you probably have old ver...

Plotting Phase angle in Matlab

First off, "load" is for Matlab files, not raw text. Check out textscan. If your code isn't error-ing, you probably have old ver...

1 month ago | 0

Answered

Change histogram to more bars

histogram accepts the number of bins as a second argument: x = randn(1000,1); nbins = 25; h = histogram(x,nbins)

Change histogram to more bars

histogram accepts the number of bins as a second argument: x = randn(1000,1); nbins = 25; h = histogram(x,nbins)

1 month ago | 1

| accepted

Answered

What is this code doing?

Short version: copy a list of Matlab script/function files from wherever Matlab finds them into a particular directory ('C:\TEMP...

What is this code doing?

Short version: copy a list of Matlab script/function files from wherever Matlab finds them into a particular directory ('C:\TEMP...

1 month ago | 0

| accepted

Answered

Extracting data from an array

To extract the first three rows: B3 = B(1:3,:); x = B3(1,:); y = B3(2,:); z = B3(3,:); But, if B is really 4x1, then you on...

Extracting data from an array

To extract the first three rows: B3 = B(1:3,:); x = B3(1,:); y = B3(2,:); z = B3(3,:); But, if B is really 4x1, then you on...

1 month ago | 0

Answered

can anyone find the error?

Perhaps you are calling the function with two few arguments, such as this on the command line: quadraticc(2) If you are simply...

can anyone find the error?

Perhaps you are calling the function with two few arguments, such as this on the command line: quadraticc(2) If you are simply...

1 month ago | 0

| accepted

Answered

Sort and extract elemets from a structure.

tables are a vastly superior way of handling this data. Does this do it? mydata= readtable('mytext.txt'); sorted_data = sortro...

Sort and extract elemets from a structure.

tables are a vastly superior way of handling this data. Does this do it? mydata= readtable('mytext.txt'); sorted_data = sortro...

2 months ago | 0

| accepted

Answered

How to extract values from each structure in the .mat file

keeps the names, but as fieldnames in a new struct, signals, rather than variables (see Walter's comment): data = load('data.ma...

How to extract values from each structure in the .mat file

keeps the names, but as fieldnames in a new struct, signals, rather than variables (see Walter's comment): data = load('data.ma...

2 months ago | 1

| accepted

Answered

Changing the size of an array in a while loop

keeps the vector the same length A_i = gradient(A_0,dt).*I.^2; changes size of vector (and uses a for loop since there are a...

Changing the size of an array in a while loop

keeps the vector the same length A_i = gradient(A_0,dt).*I.^2; changes size of vector (and uses a for loop since there are a...

2 months ago | 0

| accepted

Answered

I have the following Matlab code that produces a x2 zoomed image of the input using Pixel Replication. How can I change it to shrink an image?

throw out every other row and column: img1 = imread(filename); N = img1(2:2:end,2:2:end);

I have the following Matlab code that produces a x2 zoomed image of the input using Pixel Replication. How can I change it to shrink an image?

throw out every other row and column: img1 = imread(filename); N = img1(2:2:end,2:2:end);

2 months ago | 0

Answered

Invalid use of -. At least one of the operands must be scalar or the operands must be the same size. The units of the operands must be commensurate.

Wherever you specify the units as 'C', put 'degC' instead

Invalid use of -. At least one of the operands must be scalar or the operands must be the same size. The units of the operands must be commensurate.

Wherever you specify the units as 'C', put 'degC' instead

2 months ago | 0

Answered

Copy files from a folder to another directory

check out dir and copyfile. My suggestion would be to create the lists of file and folders first, check them, then do something ...

Copy files from a folder to another directory

check out dir and copyfile. My suggestion would be to create the lists of file and folders first, check them, then do something ...

2 months ago | 0

Answered

How can i create a vector having 6 values between two numbers

Assuming you want them evenly spaced: x = linspace(2,12,6); If you want them randomly spaced x = [2 ; 2+(12-2)*rand(4,1) ; ...

How can i create a vector having 6 values between two numbers

Assuming you want them evenly spaced: x = linspace(2,12,6); If you want them randomly spaced x = [2 ; 2+(12-2)*rand(4,1) ; ...

2 months ago | 0