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

2 months ago | 0

| accepted

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...

2 months ago | 2

| accepted

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(:...

2 months ago | 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....

2 months ago | 0

| accepted

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...

2 months ago | 0

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...

2 months ago | 1

| accepted

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 ...

2 months ago | 10

| accepted

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...

2 months ago | 0

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

2 months ago | 1

| accepted

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...

2 months ago | 1

| accepted

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...

2 months ago | 0

| accepted

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...

2 months ago | 1

| accepted

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....

2 months ago | 0

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...

2 months ago | 0

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 ...

2 months ago | 1

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, ...

2 months ago | 0

| accepted

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...

2 months ago | 0

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

2 months ago | 0

| accepted

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...

2 months ago | 0

| accepted

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

I'm not sure what im doing wrong on this script...
See TUTORIAL: Why Variables Should Not Be Named Dynamically (eval) Hint: %% C.black = 0; C.brown = 1; C.red = 2; C.orange...

2 months ago | 0

string to text file
This creates a textfile, which notepadd++ opens. v1=str(:,1); v2=str(:,2); v3=str(:,3); T = table( v1,v2,v3 ); writetable(...

3 months ago | 0

| accepted

Merge same field of 36 structures
Try this %% numfiles = length(filenames); results = cell(numfiles, 1); for K = 1 : numfiles datastruct = load( filename...

3 months ago | 0

access data in table using for loop
Try something like this %% idx = {'OMFGA','MBNC'}; OMFGA = cell( 1, numel(idx) ); for ii=1:numel(idx) B = strcmp(compTi...

3 months ago | 0

How to extract values to create a table on excel?

3 months ago | 0

Dependent property is shown in the variable editor even before its get method
"before I invoke its get method, its value is shown" Yes, that's is obviously the case, but I fail to find this behaviour desc...

3 months ago | 0

| accepted

Imported a large csv file into MATLAB - which output type should I choose?
"I have a table" I assume that's a text file See readtable, Create table from file

3 months ago | 0

Adding an outer for loop for a plot
This is may approach. (Don't change the code that works.) function cssm( ) eta = [ 4.0, 4.2, 4.7 ]; for e = eta ...

3 months ago | 0

choose 2 random unique element inside cell
See datasample, Randomly sample from data, with or without replacement and try >> cellfun( @(row) datasample( row, 2, 'repla...

3 months ago | 0

| accepted