Answered
Interpolate between columns within matrix to remove glitched data
% a random matrix with 27 columns: data = rand(10,27); % glitch columns 25 and 26: data(:,[25 26]) = NaN; % show columns...

4 years ago | 0

| accepted

Answered
Concatenate array using square brackets
https://www.mathworks.com/help/matlab/ref/double.horzcat.html

4 years ago | 1

| accepted

Answered
Second to last row?
% unzip the zip file to get the txt file % (you won't have to do this since you have the txt file already): unzip('Obs_Node.tx...

4 years ago | 0

Answered
"Scalar structure required for this assignment" error when adding struct into existing struct.
[struct2.d] = deal(struct1.d)

4 years ago | 0

| accepted

Answered
Can somebody show me how to fix these errors I am getting in my script?
Use a function handle rather than a character vector (and put the multiplications in there explicitly). For example: root1 = r...

4 years ago | 0

| accepted

Answered
Change a variable till a condition is met
% point 1 SDa = 0.08 % std of A SDb = 0.15 % std of B x = 0 % weight of A y = 1-x % weight of B p = -1 % correlation coeffi...

4 years ago | 1

| accepted

Answered
I am getting an error that matlab does not recognize the function filter1 even though it is a matlab built-in function
filter1 is not a built-in function, but it is available on the File Exchange: https://www.mathworks.com/matlabcentral/fileexcha...

4 years ago | 0

Answered
plotting outline boundary of gridded value data.
load('test_data_for_boundary.mat'); surface(x,y,data_zh11) hold on idx = ~isnan(data_zh11); good_x = x(idx); good_y =...

4 years ago | 0

Answered
code vectorization: assign numbers or datetime/durations to cell arrays, without any loop
Use sub2ind. Case 1: a = cell(3,3); index = [1 1 2 1]; idx = sub2ind(size(a),index(:,1),index(:,2)); a(idx) =...

4 years ago | 0

| accepted

Answered
Split 1x2 cells into two seperate "doubles"
C = {{1,-534},{2,-532},{3,534}}; temp = vertcat(C{:}) A = [temp{:,1}] B = [temp{:,2}]

4 years ago | 1

| accepted

Answered
How can I find the continous time between two points( ex 1,2,3,4,5,6,7,8,9,10 in between 1 and 10)
Here's your table: DeltaShortTable = table( ... [20390; 22578; 25894; 29041; 31924; 34937; 37982; 41045; 44022; 46905; 496...

4 years ago | 1

Answered
Move a portion of one table into another, smaller, table.
table_A = array2table([ ... .98 .3 .9; .94 .1 .3; .67 .1 .3; .56 .7 .4; .72 .4 .3; .64 .6 .2], .....

4 years ago | 0

| accepted

Answered
How to make a 2D pseudocolor (pcolor) plot in triangle shapes instead of a square shape with triangle cordinates data?
load('data1.mat') x = reshape(a1(1:end-1),3,[]) y = reshape(b1(1:end-1),3,[]) patch(x,y,c1) colorbar

4 years ago | 1

| accepted

Answered
Save data from for loop into array
Max(i)=MaxForces gives an error when i == 0, because indexing starts at 1. Furthermore, i goes 0, 3, 6, ..., and I imagine you ...

4 years ago | 0

| accepted

Answered
When checking to see if a variable has been created within a struct, "exist" and "isfield" both come back 0 when the struct variable exists and is populated.
Do it like this: isfield(EEG_temp,'etc') && isfield(EEG_temp.etc,'clean_channel_mask') In other words, check that 'etc' is a f...

4 years ago | 2

| accepted

Answered
how to get a part of a number
x = 1234567891011112; x_str = num2str(x) x_str = x_str([5 6]) str2double(x_str)

4 years ago | 0

Answered
Sort Matrix according to another Vector
A = [1 3 4 7 2]'; B = [3 4 7 1 2; 1 2 3 4 5; 6 7 8 9 10]'; [~,idx] = ismember(A,B(:,1)); B = B(idx,:)

4 years ago | 2

| accepted

Answered
How do I prevent MATLAB from converting characters into their ASCII equivalent?
number = 7; char_vector = repmat('*',1,number); disp(char_vector);

4 years ago | 0

Answered
How can I convert 5.000000e-01 to 0.5 in Matlab? Please help. Thank you so much.
format longE 0.5 format longG 0.5 Documentation: format

4 years ago | 0

Answered
Browsing through figures, without opening them all
You can use load to inspect .fig files programmatically: f = figure(); plot(1:10,'ButtonDownFcn','disp(''ok'')'); saveas(f,'1...

4 years ago | 0

Answered
How to set y axis limit same for 2 subplots in a figure object?
Store the axes objects returned from subplot(), and then set their YLim: features = 99; for feature = 1:numel(features) h...

4 years ago | 0

| accepted

Answered
Error using horzcat Dimensions of matrices being concatenated are not consistent.
Here's how you can add zeros to the beginning and end of your signal (with the extra zero going to the end in case the number of...

4 years ago | 0

| accepted

Answered
Hi, I have the following 1x10 matlab structure where all 10 elements are column vectors of varying sizes. Need to convert it to matrix as described below. Any help?
If S is your struct array and M is your matrix of zeros: for ii = 1:numel(S) M(ii,1:numel(S(ii).times)) = S(ii).times; en...

4 years ago | 1

| accepted

Answered
I'm trying to graph a function on an interval, and the graph either doesn't show up or is the wrong graph
x = linspace(-2,16,100); % y = (4*cos(x))./(x.*exp(x.*-0.75)); y = (4*cos(x))./(x+exp(x.*-0.75)); % ^ <---- h...

4 years ago | 0

Answered
Adding a string in front of every variable in a table
% read the table t = readtable('Ztable.xlsx','VariableNamingRule','preserve'); % modify the variable names t.Properties.Var...

4 years ago | 0

| accepted

Answered
Index exceeds the number of array elements. Index must not exceed 1.
This line: T=T(i) takes the ith element of T and stores it as T, after which T is a variable with one element. So any subseque...

4 years ago | 1

| accepted

Answered
help with smooth curve
Like this? x = 2:2:20; y = [1.23 0.95 1.1 1.44 1.47 1.1 1.21 1.4 1.1 1.39]*1e4; plot(x,y) x_new = 2:0.2:20; y_new = inter...

4 years ago | 0

Answered
Read a punch file
This may work: % read the file contents as a char vector: fid = fopen('sample.txt'); % (had to change extension to txt to uplo...

4 years ago | 0

Answered
Change axis color on parts of the mesh
Here's one way: [X,Y] = meshgrid(1:0.5:10,1:20); Z = sin(X) + cos(Y); C = 1 + (X <= 2 | X >= 9); surf(X,Y,Z,C) colormap([1 ...

4 years ago | 0

| accepted

Answered
I want to fix the zeros values in their same indices in certain two matrices A and B (to not be updated) in a cost function?
A = [0.1 0.2 0; 0.2 0.8 0; 0 0 0.7] newA = [1 2 3; 4 5 6; 7 8 9] idx = A == 0; A(~idx) = newA(~idx)

4 years ago | 0

Load more