Answered
Implementing ellipsis, also known as dot dot dot or "..." for line continuation in a regular expression statement
When you use ellipses inside a character array, you have to end it on that line, start it again on the next line, and concatenat...

4 years ago | 0

Answered
How can I plot this function below?
t = -10:0.001:10; y = cos(t.^2); plot(t,y); xlabel('t'); ylabel('y = cos(t^2)');

4 years ago | 0

| accepted

Answered
How can i find the two consecutive numbers in an array that are the upper and lower bound of a number that isn't in the same array?
y = [1 2 3 4 5 6 7 8 9 10]; x = 3.64; x_sup = min(y(y >= x)) x_inf = max(y(y <= x))

4 years ago | 1

| accepted

Answered
How to do 3D plot using both contourf and surf plot?
It may be convenient to put both the surface and the contour in the same axes. Of course an axes can only have one colormap, so,...

4 years ago | 0

| accepted

Answered
How to end an indefinite loop?
Regarding why the loop never stops, I believe there is a mistake here: T(9) = (T(6)+2*T(8)+T(12)+100); That line should be: T...

4 years ago | 0

| accepted

Answered
ignoring extra legend entries
The warning "Ignoring extra legend entries" happens if you call legend() with more names than there are lines in your axes. In t...

4 years ago | 1

Answered
How to index a cell array of character vectors?
% If si and ei are cell arrays containing scalar indices: c = {'indexing'; 'a cell array'; 'of character'; 'vectors'}; si = {1...

4 years ago | 0

| accepted

Answered
use of "break"
If you are using the value of boundary immediately after that for loop, then you are using the value of boundary corresponding t...

4 years ago | 0

| accepted

Answered
how to only clear data in fig
Seems like your best bet in this situation would be to create those lines before your for loop and then set their XData, YData, ...

4 years ago | 0

| accepted

Answered
I want to change cell array to string.
Here are a few different things you can try, depending on your purposes: C = {'abc = 1' 'def = 2' 'cba = 3' 'fed = 4' 'sag = 5'...

4 years ago | 0

| accepted

Answered
Make first and last element of array 0
Pre-allocate TAU as a vector of zeros, then just set elements 2 through N-1: N = 12*0.5; TAU_max = 15; TAU = zeros(N,1); % pr...

4 years ago | 1

Answered
How do I remove individual columns from each cell in cell array?
load('baskets_data.mat'); disp(baskets_data); baskets_xyz = cell(size(baskets_data)); for i = 1:numel(baskets_data) bask...

4 years ago | 0

| accepted

Answered
Can you make a plot that updates based off a separate GUI?
This is definitely possible. In MATLAB there are two different sets of GUI components you can use. One is figure()'s and their ...

4 years ago | 0

Answered
How can I solve such questions in matlab (fix the error)
f is a different size than t, so x is a different size than v. Define t and f to be the same size and it'll work. Here, I calcul...

4 years ago | 0

| accepted

Answered
extract from strring row symbol
A=["abcd";"efgh";"ijklm"] row_symbol_idx = [3 3]; symbol = extract(A(row_symbol_idx(1)),row_symbol_idx(2))

4 years ago | 0

| accepted

Answered
shift matrix to the right
Maybe use interp1() (or resample()): nx = 20; x = randn(1,nx); % xr = resample(x,4,1); xr = interp1(1:nx,x,1:0.25:nx); figu...

4 years ago | 1

Answered
Strange function fit to data points- sorting by first column vals?
I think it is the points not being in monotonic order in T4, and sorting them first will fix it, like you say. % T4 values to u...

4 years ago | 0

| accepted

Answered
Merge columns (date & times) into single column with correct format
% generating column vectors of Year, Day and Hour like you have in your table: n = 366; Year = 2016*ones(n*24,1); [Day,Hour] ...

4 years ago | 0

| accepted

Answered
Too many output arguments when trying to set a variable to the matrix of a program I wrote.
If you want your function to return output(s), you have to define it to do so. Here I have defined gaussify() to have one output...

4 years ago | 0

| accepted

Answered
I have an error: Unable to perform assignment because the size of the left side is 1-by-1 and the size of the right side is 17-by-6-by-5. How can I fix this?
There were some mistakes regarding using the entire arrays Ax, Ay and E when you meant to use one element, and trying to index t...

4 years ago | 0

Answered
Assign a specific Value to Marker Size in relation with axes
MarkerSize is in points (not pixels). You can do a conversion from axes data units (meters in this case) to the width of the ax...

4 years ago | 1

| accepted

Answered
How do I add a column of zeros to the end of a matrix inside a cell?
Maybe this? load('baskets_xyz.mat') baskets_xyz(:,10) = {0}

4 years ago | 0

| accepted

Answered
One row Multiple column data handling using for loop
If you want A to have all elements of a, followed by all elements of b, followed by all elements of c, you can just concatenate ...

4 years ago | 0

| accepted

Answered
How can I fix the error "Index in position 2 exceeds array bounds. Index must not exceed 1.
outcomes was defined as a string array, so it should be indexed with () not {}. And there was a typo after the elseif line ("out...

4 years ago | 0

Answered
How to index a cell array in a for loop
Your code is overwriting base_obs each time through the loop. You can make base_obs a cell array, with each cell containing a m...

4 years ago | 0

Answered
How to read array from a text file into each row of a matrix.
fid = fopen('input.txt'); data = str2num(fread(fid,'*char').'); fclose(fid); disp(data);

4 years ago | 0

Answered
Define permutation map on {1,2,3}
% you can index into a vector: S_vec = [2 3 1]; % or you can define an anonymous function: S_func = @(x)mod(x,3)+1; % th...

4 years ago | 1

Answered
How to rotate a line drawn by two points by angle 0.1:0.1:1 using a for loop?
Math reference: Rotation Matrix. Rotation about point A: a = [3 1]; b = [10 3]; angle = 0.1:0.1:1; figure(); plot([a(1) ...

4 years ago | 0

| accepted

Answered
How do you make a matrix with alternating numbers in a nested loop?
N = 5; % start with a matrix of all 3's % (then the code will place 2's at the appropriate places) Y = 3*ones(N); % loop ove...

4 years ago | 0

| accepted

Answered
Plotting a cell array
xy = vertcat(J{:}); plot(xy(:,1),xy(:,2),'.');

4 years ago | 0

| accepted

Load more