Answered

Summing without nested loops

Caveat: not tested The loops are still there, but this is significantly faster. Comments: The calculation of besselj() domin...

Summing without nested loops

Caveat: not tested The loops are still there, but this is significantly faster. Comments: The calculation of besselj() domin...

10 hours ago | 0

Answered

How do I read a block of data from excel sheet and store it in an array?

This solution uses a containers.Map rather than a cell array because I think there might be gaps in the flight_list. See contai...

How do I read a block of data from excel sheet and store it in an array?

This solution uses a containers.Map rather than a cell array because I think there might be gaps in the flight_list. See contai...

18 hours ago | 0

| accepted

Answered

How to convert a cell array of structs into a table?

So far so good. What to do with the field, "photos"? >> S=data.messages; >> sas = [S{[1:10]}]; >> struct2table(sas) ans = ...

How to convert a cell array of structs into a table?

So far so good. What to do with the field, "photos"? >> S=data.messages; >> sas = [S{[1:10]}]; >> struct2table(sas) ans = ...

6 days ago | 0

Answered

Correct way to specify default property values when constructor uses inputParser.

The default values of properties in the properties block are assigned once when the first object is created . Subsequent objects...

Correct way to specify default property values when constructor uses inputParser.

The default values of properties in the properties block are assigned once when the first object is created . Subsequent objects...

7 days ago | 1

| accepted

Answered

express function as function handles

See Create Function Handle and try fh = @dint2; What's density() ?

express function as function handles

See Create Function Handle and try fh = @dint2; What's density() ?

10 days ago | 0

Answered

Concatenate a column of cells into a single array

cat() is also a possiblity Y = cat( 2, X{:} ); Example >> X = { rand(4,1), rand(4,1), rand(4,1) } X = 1×3 cell array ...

Concatenate a column of cells into a single array

cat() is also a possiblity Y = cat( 2, X{:} ); Example >> X = { rand(4,1), rand(4,1), rand(4,1) } X = 1×3 cell array ...

10 days ago | 0

Answered

Code to run script multiple times

Assumtions: NFRO3Rec is a function that "accepts a vector x and returns a vector F" r is not changed in your code Alternate s...

Code to run script multiple times

Assumtions: NFRO3Rec is a function that "accepts a vector x and returns a vector F" r is not changed in your code Alternate s...

16 days ago | 2

Solved

Project Euler: Problem 8, Find largest product in a large string of numbers

Find the greatest product of five consecutive digits in an n-digit number. 73167176531330624919225119674426574742355349194934...

17 days ago

Answered

how to initialize the data from .txt data?

Try >> m1 = dlmread('H:\m\cssm\TESTRATE.txt'); >> m2 = dlmread('H:\m\cssm\DATANAME.txt'); >> whos m* Name Size ...

how to initialize the data from .txt data?

Try >> m1 = dlmread('H:\m\cssm\TESTRATE.txt'); >> m2 = dlmread('H:\m\cssm\DATANAME.txt'); >> whos m* Name Size ...

19 days ago | 1

Answered

Reference To Non-Existent Field

I have reproduced the error you see - sort of. Running FruitCalculations_main on R2018b throws an error >> FruitCalculations_m...

Reference To Non-Existent Field

I have reproduced the error you see - sort of. Running FruitCalculations_main on R2018b throws an error >> FruitCalculations_m...

19 days ago | 0

| accepted

Answered

How do i break a loop at set values to NaN

Try if alpha(i)<(-pi)||alpha(i)>(pi) x(i+1:end)=NaN; alpha(i+1:end)=NaN; break end

How do i break a loop at set values to NaN

Try if alpha(i)<(-pi)||alpha(i)>(pi) x(i+1:end)=NaN; alpha(i+1:end)=NaN; break end

20 days ago | 0

| accepted

Answered

How can I tell which modules are being used in my program?

Try [flist,plist] = matlab.codetools.requiredFilesAndProducts('your_program_name'); the answer is in plist - hopefully See m...

How can I tell which modules are being used in my program?

Try [flist,plist] = matlab.codetools.requiredFilesAndProducts('your_program_name'); the answer is in plist - hopefully See m...

20 days ago | 2

| accepted

Answered

Sorting from highest to lowest for a particular column

Try this %% C1 = nan( size( B(:,1:end-1) ) ); %% for rr = 1 : size(B,1) C1( rr, 2 ) = A( B(rr,2), B(rr,3) ); end C1(:...

Sorting from highest to lowest for a particular column

Try this %% C1 = nan( size( B(:,1:end-1) ) ); %% for rr = 1 : size(B,1) C1( rr, 2 ) = A( B(rr,2), B(rr,3) ); end C1(:...

20 days ago | 1

Answered

Exporting data from for loop into text file

"gives me all the data in a row:" This script produces two columns %% BOLD = reshape( (1:6), [],1 ); x = (1:size(BOLD,1))./1....

Exporting data from for loop into text file

"gives me all the data in a row:" This script produces two columns %% BOLD = reshape( (1:6), [],1 ); x = (1:size(BOLD,1))./1....

22 days ago | 0

| accepted

Answered

four dimensions array's expression

>> size(B) ans = 2 3 1 3 the statement B = cat(4,A(:,:,1),A(:,:,2),A(:,:,3)) concatenates three 2D a...

four dimensions array's expression

>> size(B) ans = 2 3 1 3 the statement B = cat(4,A(:,:,1),A(:,:,2),A(:,:,3)) concatenates three 2D a...

23 days ago | 0

Answered

How can I multiply one output of this function with another output from this function?

comment out clear all; run the script rename Tp run the a second time Or convert the script to a function that returns Tp a...

How can I multiply one output of this function with another output from this function?

comment out clear all; run the script rename Tp run the a second time Or convert the script to a function that returns Tp a...

23 days ago | 1

| accepted

Answered

How to find the index of the closest value to some number in 1D array ?

Hint: >> [ d, ix ] = min( abs( x-val ) ); >> x(ix-1:ix+1) ans = -1.0360 -1.0270 -1.0180 ix is the ...

How to find the index of the closest value to some number in 1D array ?

Hint: >> [ d, ix ] = min( abs( x-val ) ); >> x(ix-1:ix+1) ans = -1.0360 -1.0270 -1.0180 ix is the ...

23 days ago | 10

| accepted

Answered

startup.m not found in local folder

This works for me. Have you set the "Start in" folder? btw: I don't think it's a good idea to put startup.m in c:\Program Fi...

startup.m not found in local folder

This works for me. Have you set the "Start in" folder? btw: I don't think it's a good idea to put startup.m in c:\Program Fi...

23 days ago | 0

Answered

how to read read a specific rows in .txt and put it in class?

The problem is caused by the first character of line 11. It's char(26) The function readtable() reads the file

how to read read a specific rows in .txt and put it in class?

The problem is caused by the first character of line 11. It's char(26) The function readtable() reads the file

25 days ago | 1

| accepted

Answered

Assigning values to an array of arbitrary dimensions in MATLAB.

"The problem I have is to be able to this with an arbitrary value of j." I think value2arrayND does that. It takes a cell array...

Assigning values to an array of arbitrary dimensions in MATLAB.

"The problem I have is to be able to this with an arbitrary value of j." I think value2arrayND does that. It takes a cell array...

1 month ago | 1

| accepted

Answered

Speeding up the manipulation of large matrices

Your code, "diff(temp,[],2)==0,2)", made me think that temp holds whole numbers. If so, you could convert temp to an appropriate...

Speeding up the manipulation of large matrices

Your code, "diff(temp,[],2)==0,2)", made me think that temp holds whole numbers. If so, you could convert temp to an appropriate...

1 month ago | 0

| accepted

Answered

How can I call the variables of MATLAB workspace from a function?

Do you have a good reason for doing this? Hint: function save_base_workspace() evalin( 'base', 'save( ''save_base_works...

How can I call the variables of MATLAB workspace from a function?

Do you have a good reason for doing this? Hint: function save_base_workspace() evalin( 'base', 'save( ''save_base_works...

1 month ago | 1

| accepted

Answered

Convert an array of numbers into letters using logical indexing

Another approach >> grades = reshape([ 6.29, 5.87, 5.28, 7.38, 7.40, 4.07, 4.23, 7.25, 3.60 ... , 4.37, 4....

Convert an array of numbers into letters using logical indexing

Another approach >> grades = reshape([ 6.29, 5.87, 5.28, 7.38, 7.40, 4.07, 4.23, 7.25, 3.60 ... , 4.37, 4....

1 month ago | 0

Answered

How to store Data in a MATLAB® data file as a MATLAB dataset object?

I successfully (R2018b) ran the example of the documentation that you linked to. Did you try it? "MATLAB dataset object" see d...

How to store Data in a MATLAB® data file as a MATLAB dataset object?

I successfully (R2018b) ran the example of the documentation that you linked to. Did you try it? "MATLAB dataset object" see d...

1 month ago | 0

Answered

How to clear the workspace from within a program?

Read Base and Function Workspaces Your program is that a script or a function? Your question makes me believe your program is ...

How to clear the workspace from within a program?

Read Base and Function Workspaces Your program is that a script or a function? Your question makes me believe your program is ...

1 month ago | 1

Answered

Windows(CR LF) to Unix (LF)

You have a few options Open the file in Notepad++ and replace CRLF by LF as shown by the screen clip below. Use the solution, ...

Windows(CR LF) to Unix (LF)

You have a few options Open the file in Notepad++ and replace CRLF by LF as shown by the screen clip below. Use the solution, ...

1 month ago | 0

| accepted

Answered

Efficiently import text file with irregular struture

See Import Block of Numeric Data from Text File and How do I parse this complex text file with textscan? If you need further...

Efficiently import text file with irregular struture

See Import Block of Numeric Data from Text File and How do I parse this complex text file with textscan? If you need further...

1 month ago | 0

Answered

Getting error message, "Subscript indices must either be real positive integers or logicals."

MATLAB has indexing of arrays beginning from 1 instead of 0, thus replace for i =0:1:75 by for i =1:1:76

Getting error message, "Subscript indices must either be real positive integers or logicals."

MATLAB has indexing of arrays beginning from 1 instead of 0, thus replace for i =0:1:75 by for i =1:1:76

1 month ago | 0

Answered

How to store columns of different lengths using cells

I assume that you intend to put successive values of trimtempstoreCol into cells of newData. To do that, replace newData{t...

How to store columns of different lengths using cells

I assume that you intend to put successive values of trimtempstoreCol into cells of newData. To do that, replace newData{t...

1 month ago | 0

| accepted

Answered

If statement correction help

"I need is to create an array of 1000 random variables from -1 to 0 and 1/2 to 1" Another approach >> X1 = rand(1,1e3)*1.5 - 1...

If statement correction help

"I need is to create an array of 1000 random variables from -1 to 0 and 1/2 to 1" Another approach >> X1 = rand(1,1e3)*1.5 - 1...

2 months ago | 0