I've worked at MathWorks since 2013. Using MATLAB isn't part of my job, but I enjoy learning about it.

Submitted

dotenv-for-MATLAB

Load environment variables from a .env file.

2 meses ago | 7 downloads |

Solved

Return unique values without sorting

If the input vector A is [42 1 1], the output value B must be the unique values [42 1] The *values of B are in the s...

casi 4 años ago

Solved

Generate N equally spaced intervals between -L and L

Given N and L, return a list of numbers (in ascending order) that divides the interval [-L L] into N equal-length segments. F...

casi 4 años ago

Solved

Set the array elements whose value is 13 to 0

Input A either an array or a vector (which can be empty) Output B will be the same size as A . All elements of A equal to 13...

casi 4 años ago

Answered

How can I create a cell array by combining arrays?

What are you having trouble with? The code you posted works. >> cellArray={['X','Y','Z'],[1 2 3],[4 5 6],[7 8 9]} c...

How can I create a cell array by combining arrays?

What are you having trouble with? The code you posted works. >> cellArray={['X','Y','Z'],[1 2 3],[4 5 6],[7 8 9]} c...

casi 4 años ago | 1

Answered

Using save with -v7.3 takes a long time and the mat file size is enormous

I've run into this before too. From the <https://www.mathworks.com/help/matlab/import_export/mat-file-versions.html matfile> pag...

Using save with -v7.3 takes a long time and the mat file size is enormous

I've run into this before too. From the <https://www.mathworks.com/help/matlab/import_export/mat-file-versions.html matfile> pag...

casi 4 años ago | 0

| accepted

Answered

How do I get Matlab to recognise a text file as numerical values when importing it ?

Check out the <https://www.mathworks.com/help/matlab/ref/textscan.html#inputarg_formatSpec |formatSpec|> portion of the textscan...

How do I get Matlab to recognise a text file as numerical values when importing it ?

Check out the <https://www.mathworks.com/help/matlab/ref/textscan.html#inputarg_formatSpec |formatSpec|> portion of the textscan...

casi 4 años ago | 0

Answered

how to get the specific member data from a struct array?

From the doc on <https://www.mathworks.com/help/matlab/ref/struct.html |struct|> "When you access a field of a nonscalar stru...

how to get the specific member data from a struct array?

From the doc on <https://www.mathworks.com/help/matlab/ref/struct.html |struct|> "When you access a field of a nonscalar stru...

casi 4 años ago | 0

| accepted

Answered

Can anybody help me in writing MATLAB code?i have an .xls file of 2950 sequence .i want a function to read my file and select sequence 1,11,21,31 and write it on another new .xls file, then select 2,12,22 and similarly uptill 10,20,30...etc

% Pseudocode T = readtable('file.xlsx'); for ii=1:10 rows = ii:10:height(T); writetable(T(rows,:), ['fil...

Can anybody help me in writing MATLAB code?i have an .xls file of 2950 sequence .i want a function to read my file and select sequence 1,11,21,31 and write it on another new .xls file, then select 2,12,22 and similarly uptill 10,20,30...etc

% Pseudocode T = readtable('file.xlsx'); for ii=1:10 rows = ii:10:height(T); writetable(T(rows,:), ['fil...

casi 4 años ago | 0

Answered

predict data for input

Have you tried <https://www.mathworks.com/help/stats/compactclassificationdiscriminant.predict.html |predict()|>? results =...

predict data for input

Have you tried <https://www.mathworks.com/help/stats/compactclassificationdiscriminant.predict.html |predict()|>? results =...

casi 4 años ago | 0

Answered

I'm trying to create a loop in which i can extract 4 columns and multiple rows from 18 difference txt files and save the extracted data in one file. Is this possible? This is my code from one file

Untested, but this should basically work. Get an array of filenames with <https://www.mathworks.com/help/matlab/ref/ls.html?s_ti...

I'm trying to create a loop in which i can extract 4 columns and multiple rows from 18 difference txt files and save the extracted data in one file. Is this possible? This is my code from one file

Untested, but this should basically work. Get an array of filenames with <https://www.mathworks.com/help/matlab/ref/ls.html?s_ti...

casi 4 años ago | 0

Answered

How can I make a random array with values of either -1 or 1?

You can use rand % pseudo code x = rand(50,1); pos = x >= .5; neg = x < .5; x(pos) = 1; x(neg) = -1; ...

How can I make a random array with values of either -1 or 1?

You can use rand % pseudo code x = rand(50,1); pos = x >= .5; neg = x < .5; x(pos) = 1; x(neg) = -1; ...

casi 4 años ago | 0

Answered

I'm doing iteration of credit card. In it, there are looping of month ,balance, and pay every month . How to plot graph with these three variable as the value changes everytime looping happen . Thanks

Don't try and plot it everytime it changes. Store the elements in vectors and plot those at the end.

I'm doing iteration of credit card. In it, there are looping of month ,balance, and pay every month . How to plot graph with these three variable as the value changes everytime looping happen . Thanks

Don't try and plot it everytime it changes. Store the elements in vectors and plot those at the end.

casi 4 años ago | 0

Solved

Elapsed Time

Given two date strings d1 and d2 of the form yyyy/mm/dd HH:MM:SS (assume hours HH is in 24 hour mode), determine how much time, ...

casi 4 años ago

Solved

Binary numbers

Given a positive, scalar integer n, create a (2^n)-by-n double-precision matrix containing the binary numbers from 0 through 2^n...

casi 4 años ago

Answered

How to remove corrupted data lines from text file

Add a NameValue pair of <https://www.mathworks.com/help/matlab/ref/textscan.html#namevaluepairs CommentStyle>. e.g., C = t...

How to remove corrupted data lines from text file

Add a NameValue pair of <https://www.mathworks.com/help/matlab/ref/textscan.html#namevaluepairs CommentStyle>. e.g., C = t...

casi 4 años ago | 0

Solved

Counting Money

Add the numbers given in the cell array of strings. The strings represent amounts of money using this notation: $99,999.99. E...

casi 4 años ago

Solved

Sums with Excluded Digits

Add all the integers from 1 to n in which the digit m does not appear. m will always be a single digit integer from 0 to 9. no...

casi 4 años ago

Solved

Multielement indexing of a row array

The row array birthRateChina stores the China birth rate (per 1000 people) for years 2000 to 2012. Write a statement that create...

casi 4 años ago

Answered

How to set names to column vectors?

If you want to associate a variable name with a piece of data I think your best bet is to use a <https://www.mathworks.com/help/...

How to set names to column vectors?

If you want to associate a variable name with a piece of data I think your best bet is to use a <https://www.mathworks.com/help/...

casi 4 años ago | 1

| accepted

Solved

Replace NaNs with the number that appears to its left in the row.

Replace NaNs with the number that appears to its left in the row. If there are more than one consecutive NaNs, they should all ...

casi 4 años ago

Answered

How to speed up a for loop ?

Are you sure this is correct? angle=asin(A(:,3))/(sqrt(A(:,3).^2+A(:,2).^2+A(:,1).^2)); That's doing matrix division. In...

How to speed up a for loop ?

Are you sure this is correct? angle=asin(A(:,3))/(sqrt(A(:,3).^2+A(:,2).^2+A(:,1).^2)); That's doing matrix division. In...

casi 4 años ago | 2

| accepted

Answered

How to find which column consists character 'example' in cell c{1,2}(:,1)

strcmp(c{1,2}(:,1), 'example') will return a logical array. You may need to surround 'example' with |cellstr()|, I can't re...

How to find which column consists character 'example' in cell c{1,2}(:,1)

strcmp(c{1,2}(:,1), 'example') will return a logical array. You may need to surround 'example' with |cellstr()|, I can't re...

casi 4 años ago | 0

Answered

how to convert minute rainfall to daily rainfall with missing value?

This assumes you can get the data into the tables you want. Here is a way if you have data in one station per file. ds = da...

how to convert minute rainfall to daily rainfall with missing value?

This assumes you can get the data into the tables you want. Here is a way if you have data in one station per file. ds = da...

casi 4 años ago | 0

Answered

Replace a missing string in a table

This should work: dblVar = [NaN; 3; 7; 9]; cellstrVar = {'one'; 'three'; ''; 'nine'}; categoryVar = categorical({''; ...

Replace a missing string in a table

This should work: dblVar = [NaN; 3; 7; 9]; cellstrVar = {'one'; 'three'; ''; 'nine'}; categoryVar = categorical({''; ...

casi 4 años ago | 1

| accepted

Answered

How to process multiple txt files in a loop?

Get an array of file names and loop over that array. e.g., files = ['file1.txt' 'file2.txt' 'file3.txt']; for ii = 1:nu...

How to process multiple txt files in a loop?

Get an array of file names and loop over that array. e.g., files = ['file1.txt' 'file2.txt' 'file3.txt']; for ii = 1:nu...

casi 4 años ago | 3

| accepted

Answered

How do I calculate a mean value of a vector and ignore from the "0" when appears inside the vectors?

Replacing the 0s with NaN and using the 'omitnan' flag should do what you want. >> A A = NaN NaN...

How do I calculate a mean value of a vector and ignore from the "0" when appears inside the vectors?

Replacing the 0s with NaN and using the 'omitnan' flag should do what you want. >> A A = NaN NaN...

casi 4 años ago | 0

Answered

How can i rotate Confusion Matrix?

ax = gca; ax.XAxisLocation = 'top'; You can also do this with the set command, but I think the above is more clear.

How can i rotate Confusion Matrix?

ax = gca; ax.XAxisLocation = 'top'; You can also do this with the set command, but I think the above is more clear.

casi 4 años ago | 0

Answered

Merge Date and Time in Tall Tables

Try adding them together. <https://in.mathworks.com/help/matlab/matlab_prog/compute-elapsed-time.html Examples>.

Merge Date and Time in Tall Tables

Try adding them together. <https://in.mathworks.com/help/matlab/matlab_prog/compute-elapsed-time.html Examples>.

alrededor de 4 años ago | 0

Answered

Extract values from single data matrix

Take a look at <https://www.mathworks.com/help/matlab/ref/horzcat.html |horzcat|> and <https://www.mathworks.com/help/matlab/ref...

Extract values from single data matrix

Take a look at <https://www.mathworks.com/help/matlab/ref/horzcat.html |horzcat|> and <https://www.mathworks.com/help/matlab/ref...

alrededor de 4 años ago | 0