Answered

How to create a new table array combining the values every n,th element from two different table arrays

In my case I would like to add every 60 values of A to add 59 consecutive values of B So, assuming that A and B are indeed vect...

How to create a new table array combining the values every n,th element from two different table arrays

In my case I would like to add every 60 values of A to add 59 consecutive values of B So, assuming that A and B are indeed vect...

6 days ago | 0

| accepted

Answered

mod gives incorrect result

See my comment to Kalyan's answer for why your naive attempt doesn't work, and learn about floating point numbers so that you ca...

mod gives incorrect result

See my comment to Kalyan's answer for why your naive attempt doesn't work, and learn about floating point numbers so that you ca...

6 days ago | 2

Answered

How do I get my matrix dimensions correct?

t_loading, v_trailertank, and co. (the random variables) are column vectors 1000 rows by 1 columns. To these you are adding x./...

How do I get my matrix dimensions correct?

t_loading, v_trailertank, and co. (the random variables) are column vectors 1000 rows by 1 columns. To these you are adding x./...

6 days ago | 0

Answered

Use rowfun to sum multiple columns by group

rowfun is not the correct function for this. rowfun applies the function by rows and consider the input variables as separate in...

Use rowfun to sum multiple columns by group

rowfun is not the correct function for this. rowfun applies the function by rows and consider the input variables as separate in...

7 days ago | 0

| accepted

Answered

"Index exceeds the number of array elements (11)."

You create a variable called disp: disp = 'RLC Circuit' %removed brackets which didn't anything Which shadows the built-in ...

"Index exceeds the number of array elements (11)."

You create a variable called disp: disp = 'RLC Circuit' %removed brackets which didn't anything Which shadows the built-in ...

7 days ago | 0

| accepted

Answered

What is the default varargin in the GUI callbacks? What are the differences between varargin{1} and varargin{2}.Source?

Yes, as Stephen says in his very thorough comment, that advice is utter rubbish. Don't do that it pointlessly obfuscate the code...

What is the default varargin in the GUI callbacks? What are the differences between varargin{1} and varargin{2}.Source?

Yes, as Stephen says in his very thorough comment, that advice is utter rubbish. Don't do that it pointlessly obfuscate the code...

10 days ago | 0

Answered

I have a Table in MATLAB. In one colum, lots of texts are seperated in comma. I wish to delimate those in seperate colums.

It's not clear what you want as an output since for each row you're going to get a different number of elements after the split....

I have a Table in MATLAB. In one colum, lots of texts are seperated in comma. I wish to delimate those in seperate colums.

It's not clear what you want as an output since for each row you're going to get a different number of elements after the split....

10 days ago | 0

| accepted

Answered

mat lab terms of use

For this you should contact Mathworks directly. We're just a bunch of volunteers here.

mat lab terms of use

For this you should contact Mathworks directly. We're just a bunch of volunteers here.

13 days ago | 0

Answered

Create an array iterating on another array

If I understood correctly: out = zeros(size(N)); for row = 1:size(N, 1) [isfound, where] = ismember(SP, G{row}(1, :)); %...

Create an array iterating on another array

If I understood correctly: out = zeros(size(N)); for row = 1:size(N, 1) [isfound, where] = ismember(SP, G{row}(1, :)); %...

13 days ago | 0

| accepted

Answered

Create new .wav files around findpeak outputs

Here's how I'd do it: infile = 'C:\somewhere\somefolder\test_100m.wav'; %I'd recommend you use full path instead of relying on...

Create new .wav files around findpeak outputs

Here's how I'd do it: infile = 'C:\somewhere\somefolder\test_100m.wav'; %I'd recommend you use full path instead of relying on...

13 days ago | 1

| accepted

Answered

calculating the number of days within each month for a range of dates

You've got to learn to work with datetime arrays. There's no need to use datenum to construct datetimes, and adjusting the defau...

calculating the number of days within each month for a range of dates

You've got to learn to work with datetime arrays. There's no need to use datenum to construct datetimes, and adjusting the defau...

14 days ago | 0

| accepted

Answered

Transformation of the Matrix in a Loop

With your invented notation it's difficult to know what you actually have in matlab. Assuming you have a matrix such as: Z = [...

Transformation of the Matrix in a Loop

With your invented notation it's difficult to know what you actually have in matlab. Assuming you have a matrix such as: Z = [...

15 days ago | 1

| accepted

Answered

Old Matlab script not running on newer version

The equivalent of your wavwrite using audiowrite is: audiowrite(fullfile(subj_name, sprintf('%d.wav', block_num)), recordedaudi...

Old Matlab script not running on newer version

The equivalent of your wavwrite using audiowrite is: audiowrite(fullfile(subj_name, sprintf('%d.wav', block_num)), recordedaudi...

17 days ago | 1

| accepted

Answered

Merging matrices by comparison of values of several columns

Nearly right [~, whichArows, whichBrows] = intersect(out1(:, 2:4), out2(:, 2:4), 'rows'); C = [out2(whichBrows, 5), out1(which...

Merging matrices by comparison of values of several columns

Nearly right [~, whichArows, whichBrows] = intersect(out1(:, 2:4), out2(:, 2:4), 'rows'); C = [out2(whichBrows, 5), out1(which...

18 days ago | 0

| accepted

Answered

Using For Loop to get different outcomes

if ismember(psi_value, [0.05, 0.15, 0.25, 0.35]) %maybe use ismembertol s_plot = 0.8; else s_plot = 0.2; end Note ...

Using For Loop to get different outcomes

if ismember(psi_value, [0.05, 0.15, 0.25, 0.35]) %maybe use ismembertol s_plot = 0.8; else s_plot = 0.2; end Note ...

18 days ago | 0

Answered

Store a group of points (given x, y, and value) into image efficiently

img = zeros(1000, 1000); img(M(:, 2) + 1000 * (M(:, 1) - 1)) = M(:, 3);

Store a group of points (given x, y, and value) into image efficiently

img = zeros(1000, 1000); img(M(:, 2) + 1000 * (M(:, 1) - 1)) = M(:, 3);

18 days ago | 1

| accepted

Answered

Negative Value when using Trapz

Can someone tell me as to why this is the case Because your x vector is decreasing, so is negative for each trapeze a = trapz...

Negative Value when using Trapz

Can someone tell me as to why this is the case Because your x vector is decreasing, so is negative for each trapeze a = trapz...

19 days ago | 0

Answered

Create two arrays on the basis of other arrays

%first find which of A or B elements are going into. Only depends on V isA = false(size(V)); %put in A (true) or B (false) lA...

Create two arrays on the basis of other arrays

%first find which of A or B elements are going into. Only depends on V isA = false(size(V)); %put in A (true) or B (false) lA...

19 days ago | 0

| accepted

Answered

Create a random sequence based on a matrix columns

A= [1 3 2 4 5 8 9 11 14; 0 0 0 7 6 12 0 0 0; 0 0 0 0 10 13 0 0 0]; %first add an extra column of 0s if the num...

Create a random sequence based on a matrix columns

A= [1 3 2 4 5 8 9 11 14; 0 0 0 7 6 12 0 0 0; 0 0 0 0 10 13 0 0 0]; %first add an extra column of 0s if the num...

19 days ago | 0

| accepted

Answered

convert nested struct to matrix

Well, you obviously can't concatenate vectors of dfferent sizes so if you want to do that you either have to trim the longer vec...

convert nested struct to matrix

Well, you obviously can't concatenate vectors of dfferent sizes so if you want to do that you either have to trim the longer vec...

19 days ago | 0

| accepted

Answered

Timetable Monthly Average over Many Years

The easiest: precip = table2timetable(readtable('CR_precip.csv')); monthlyavg = groupsummary(precip, 'day', 'monthofyear', 'me...

Timetable Monthly Average over Many Years

The easiest: precip = table2timetable(readtable('CR_precip.csv')); monthlyavg = groupsummary(precip, 'day', 'monthofyear', 'me...

19 days ago | 1

| accepted

Answered

How to extract strings from a table?

Why is the size of the array hardcoded (which means the code will break if something change with the file) instead of just askin...

How to extract strings from a table?

Why is the size of the array hardcoded (which means the code will break if something change with the file) instead of just askin...

19 days ago | 0

| accepted

Answered

Combining consecutive vectors into a matrix

You must have changed the options of the wizard to specifically create variables from the columns of the excel spreadsheet. Don'...

Combining consecutive vectors into a matrix

You must have changed the options of the wizard to specifically create variables from the columns of the excel spreadsheet. Don'...

19 days ago | 1

Answered

Index in position 2 exceeds array bounds (must not exceed 4).

I don't know what else you expect from your code. You purposefully create an array data with 4 columns and then write: .. = 1/...

Index in position 2 exceeds array bounds (must not exceed 4).

I don't know what else you expect from your code. You purposefully create an array data with 4 columns and then write: .. = 1/...

20 days ago | 0

Answered

how can I save the data generated from a function that depends on 3 parameters

Assuming the outputs of proprad are all scalar: [Wpig, chla, starch_content] = ndgrid(3:0.5:8, 0.6:0.2:0.5, 2:4:52); [Waveleng...

how can I save the data generated from a function that depends on 3 parameters

Assuming the outputs of proprad are all scalar: [Wpig, chla, starch_content] = ndgrid(3:0.5:8, 0.6:0.2:0.5, 2:4:52); [Waveleng...

20 days ago | 0

Answered

How to convert data with 3Dimensions to cell array

The simplest is: B = num2cell(A, [1, 2]); %keep rows and columns together, split the pages This will give you a 1x1x2353 cell...

How to convert data with 3Dimensions to cell array

The simplest is: B = num2cell(A, [1, 2]); %keep rows and columns together, split the pages This will give you a 1x1x2353 cell...

20 days ago | 0

| accepted

Answered

Saving textfiles in a other folder

It's never a good idea to modify the matlab path (with addpath or others) just to read or write data files. The simplest way t...

Saving textfiles in a other folder

It's never a good idea to modify the matlab path (with addpath or others) just to read or write data files. The simplest way t...

20 days ago | 0

| accepted

Answered

How can I merge a row from one table to a second table with more data based on name?

it's not clear what you want the new table to be, nor what you want to do afterward with it (save it?). Here's a start. Adapt as...

How can I merge a row from one table to a second table with more data based on name?

it's not clear what you want the new table to be, nor what you want to do afterward with it (save it?). Here's a start. Adapt as...

22 days ago | 0

Answered

fsolve on polynominal function

Solving is the same as solving , which is easily solved with roots: roots([a, b, c-1]) your myfun doesn't make much sense: y...

fsolve on polynominal function

Solving is the same as solving , which is easily solved with roots: roots([a, b, c-1]) your myfun doesn't make much sense: y...

25 days ago | 0

Answered

How do I make matrix of ones and zeros alternating depending on size and elements of an array?

Here's a fairly simple way: B = zeros((numel(A)+1)/2, sum(A)); for row = 1:2:numel(A) B(ceil(row/2), :) = repelem([0, 1, ...

How do I make matrix of ones and zeros alternating depending on size and elements of an array?

Here's a fairly simple way: B = zeros((numel(A)+1)/2, sum(A)); for row = 1:2:numel(A) B(ceil(row/2), :) = repelem([0, 1, ...

25 days ago | 1