Answered
xlsread() not reading entire values in column
As an alternative to @Cris LaPierre's answer, for instance If manipulating the file(s) in Excel is not feasible because, say, th...

5 years ago | 1

Answered
Separation of Specific Columns from a Text File
"The text file also conatins string as well." This is the problem. You would need to tell textscan() to skip that header text. ...

5 years ago | 0

Answered
Multidimensional Array deleting entire max record keeping information across in order
If all you need is the 20 maximum values and their positions (either linear index or subscript index), then you can do this: sh...

5 years ago | 0

| accepted

Answered
Error using horzcat in code trying to get rid of discontinuities
This error happens because 0 is a scalar (i.e., it has size 1 in all dimensions) and diff(y) is of size not equal to 1 in some d...

5 years ago | 1

| accepted

Answered
Compare row i with subsequent rows until they are equal
It's not entirely clear to me what the output should be. You say you want to "get the value of all the rows which are the same"....

5 years ago | 0

| accepted

Answered
Inserting non zero element in diagonal position of a nonzero matrix
If I understand what you are trying to do, here is one way. I got some discrepancies between this code's output A and the A you ...

5 years ago | 1

Answered
Count number of unique .mat files in a folder
Your code appears to be collecting information (dirinfo, folders) about sub-directories within the given rootPath, and then also...

5 years ago | 0

| accepted

Answered
Convert 385*360 cell array containing 1*33 vector into 1*360 Matrix containing 385*33 double
Here is one way to do it: n = size(Node_all,2); All_Nodes_complete = cell(1,n); for j = 1:n All_Nodes_complete{j} = vert...

5 years ago | 0

| accepted

Answered
Convert nested cell array into single cell array
A = {{[1] [2] [3]} {[4] [5] [6]}}; B = cellfun(@(x)[x{:}],A,'UniformOutput',false); display(A); display(B);

5 years ago | 1

| accepted

Answered
Character exclusion using ischar() in script.
Use the 's' option in your call to input(), which takes the input as a character array and does not interpret or evaluate it. Th...

5 years ago | 1

| accepted

Answered
How to end the while true loop? Whenever I enter the "Yes" and "No" under case 'Yes' or case 'No', after showing the answer then it will return to 4th line of val = input....
The break statement breaks out of the inner while true loop, but you need another break statement after the inner loop to break ...

5 years ago | 1

| accepted

Answered
logical indexing from matrix to vector
Here is one way: A=rand(4,5); B=rand(4,5); C=rand(4,5); display(A); display(B); display(C); D=logical([1 0 0 0 0; 0 0...

5 years ago | 0

| accepted

Answered
Plotting lines in subsequent color order, line marker and line style.
symbolList = [ 'o', '+', '*', '.', 'x', '_', '|', 's', 'd', '^', 'v', '>', '<', 'p', 'h', 'none']; symbolList = 'o+*.x_|sd^v><p...

5 years ago | 0

| accepted

Answered
Can you help me guys i cant plot this this graph using matlab
t = [-7.8 -6 -5 -3 -2 0 1 3 4 6 7 9 10 11]; x = [0.2 2 0 2 0 2 0 2 0 2 0 2 0 1]; figure('Units','pixels','Position',[1 1 500 1...

5 years ago | 0

Answered
changing values in matrix to numbers from particular range
X = [1,5,10,14,25;22,30,28,4,2]; display(X); X(X >= 1 & X <= 5) = 1; X(X >= 6 & X <= 10) = 2; % and so on for the rest of ...

5 years ago | 0

| accepted

Answered
Summation function to calculate Mu
The sum over j depends on i, so you must call sumLsf each time through the i loop function Mu = Muf(n, D, S, X, L) Mu = 0; fo...

5 years ago | 1

| accepted

Answered
Assign some vector's values to an Identify matrix
A(logical(A)) = x;

5 years ago | 0

| accepted

Answered
Variables aren't being plotted correctly, no errors within code and I don't know why.
I would check on this: tmp = exist(thisFile,'file'); ice = ncread(tmpFile,'sea_ice_area_fraction'); lat = ncread(tmpF...

5 years ago | 0

Answered
Extract only a few arrays from all the available combinations of them, but without calculate all of them
Here's a way to do it with recursion. It seems to give the right result with the relatively small values I tested it on. It's pr...

5 years ago | 0

| accepted

Answered
How do I iterating through a struct with several levels?
First, a point of clarification: the mat-file attached to the question contains a struct with three fields, each of which is an ...

5 years ago | 0

| accepted

Answered
Callback function for uitables with multiple tabs in app designer
app.TabGroup = uitabgroup('Parent', app.UIFigure, 'Position', [20, 20, 100, 150], 'SelectionChangedFcn',{@tabChanged, app.UIFigu...

5 years ago | 0

Answered
How to turn a matrix into a vector?
I'm not sure what you mean by "assigning a value (index) to each one", but you can use the colon operator to put all the values ...

5 years ago | 2

| accepted

Answered
Separating a CSV into multiple CSVs by an ID within the CSV, using that ID as the new filename
Here's an approach that uses readcell()/writecell() rather than readmatrix()/writematrix() because we need to know the header in...

5 years ago | 1

Answered
Digraph: for all nodes calculate all successors
Here is one way: all_S = cell(G.numnodes,1); for i = 1:G.numnodes all_S{i} = successors(G,G.Nodes{i,1}); end

5 years ago | 0

| accepted

Answered
Mean of multiple arrays in a 19x1 cell
It's probably easiest to concatenate the elements of the cell array into a 3-dimensional numeric array: C = repmat({randi(255,1...

5 years ago | 0

Answered
How to Index Simulated Markov Chain?
Note that the variable success is initialized to 0: success=0; and then only ever incremented by its own value: success=succ...

5 years ago | 0

Answered
HOW TO USE FOR LOOP FOR MY PROGRAM
Maybe something like this would work: % Clear the workspace and the screen sca; close all; clear; % Here we call some defau...

5 years ago | 1

| accepted

Answered
Confronting column values of two rows in a table?
t = load('Table.mat'); t = t.Comp; names = {'T' 'P1'}; [~,idx] = max(t.GWP(ismember(t.Name,names))); max_name = names{idx}...

5 years ago | 1

| accepted

Answered
Subsetting variables in bar function gives a zero for excluded x-values.
I'm not sure this is the best way (in fact I'm pretty sure it's not), but it seems to do the job: x = categorical({'a','b','c'}...

5 years ago | 1

Load more