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

casi 4 años hace | 0

| aceptada

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

casi 4 años hace | 1

| aceptada

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

casi 4 años hace | 0

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

casi 4 años hace | 0

| aceptada

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

casi 4 años hace | 0

| aceptada

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

casi 4 años hace | 1

| aceptada

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

casi 4 años hace | 0

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

casi 4 años hace | 0

Respondida
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) =...

casi 4 años hace | 0

| aceptada

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

casi 4 años hace | 1

| aceptada

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

casi 4 años hace | 1

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

casi 4 años hace | 0

| aceptada

Respondida
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

casi 4 años hace | 1

| aceptada

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

casi 4 años hace | 0

| aceptada

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

casi 4 años hace | 2

| aceptada

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

casi 4 años hace | 0

Respondida
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,:)

casi 4 años hace | 2

| aceptada

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

casi 4 años hace | 0

Respondida
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

casi 4 años hace | 0

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

casi 4 años hace | 0

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

casi 4 años hace | 0

| aceptada

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

casi 4 años hace | 0

| aceptada

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

casi 4 años hace | 1

| aceptada

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

casi 4 años hace | 0

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

casi 4 años hace | 0

| aceptada

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

casi 4 años hace | 1

| aceptada

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

casi 4 años hace | 0

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

casi 4 años hace | 0

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

casi 4 años hace | 0

| aceptada

Respondida
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)

casi 4 años hace | 0

Cargar más