Answered
I have a big string of code. There is a variable at the top that affects many different calculations, which I want to increment in a 1 in a loop for a desired value.
Your code could have some structure like this: % presuming these don't depend on the value of dda, they can be % calculated o...

2 months ago | 0

| accepted

Answered
The while loops works when X/Y is defined in the while loop, but won't run when X/Y is defined in the code above it. I need a while loop that works using the code above it.
In the first while loop, X/Y is calculated and compared to P on each iteration. No problem. In the second while loop, bob is co...

2 months ago | 0

Answered
Help with findgroups/splitapply, and general deep learning help.
FCTable = load('FCTable.mat').FCTable T = FCTable; T.tradeDate_shift = dateshift(T.tradeDate,'start','day'); T.EFA_catego...

2 months ago | 0

| accepted

Answered
What is the correct syntax to assign simulated data to my variables?
This may be a useful reference: G_var_list = {'log_y','C','pi_ann','B_nominal','B','sp','i_ann','r_real_ann','P'}; irfs_var_li...

2 months ago | 1

Answered
I have an equation. I want to adjust one of the values in the equation until it hits a certain output. How do I run a loop to increment that certain value until it does this?
X=21; Y=4; P=3; while X/Y > P Y = Y+1; end % this Y % is the first value of Y such that X/Y <= P X/Y <= P % (t...

2 months ago | 0

Answered
simulating rolling 1 and 2 dice
% define a function that creates the plots for a given set of results % (roll) and corresponding number of dice (n_dice) and nu...

2 months ago | 0

Answered
defining upper and lower limits of a matrix
Load and visualize data etan = load('viscosity_test.mat').etan; % check the min and max value of etan [etan_min,etan_max] =...

2 months ago | 1

| accepted

Answered
Why is trailing back space removed from my folder name?
I don't know why the trailing backslash is missing from app.OutLoc. Maybe app.defOutLoc is not the same as defOutLoc. Anyway, y...

2 months ago | 0

Answered
sprintf
files = {'U02B.HHZf';'U04B.HHZf';'U05B.HHZf';'U06B.HHZf'}; keep = true(size(files)); dirs = {'some\directory'}; i = 1; tmp...

2 months ago | 0

Answered
Reshape EEG data to wide format with new aggregate column names
% a table ID = ["01-02";"01-02";"01-02";"01-02";"01-02";"01-02";"01-02";"01-12";"01-12";"01-12";"01-12";"01-12";"01-12"]; Elec...

2 months ago | 2

| accepted

Answered
Legend for tiled donut charts
Here's something that may help. n = 3; data = rand(10,n); f = figure(); tl = tiledlayout(2,n); d = gobjects(n,1); for ii...

2 months ago | 1

| accepted

Answered
Variable Names not being read into uitable using readmatrix
Using C = table2array(C) makes C a numeric array rather than a table array. Numeric arrays only contain numbers (no information ...

2 months ago | 0

| accepted

Answered
Extracting Data from Table
If FFF1.x_coordinate == xv1(i) gives a different result than FFF1.x_coordinate == 0.25, then xv1(i) is not equal to 0.25. You do...

2 months ago | 0

Answered
Add a colorbar for this quiver plot
figure hold on NColors = 10; scale_factor = 0.02; sr = sqrt(sx.^2+sy.^2); [sr_min,sr_max] = bounds(sr,'all'); qidx = discr...

2 months ago | 0

| accepted

Answered
How can I insert data into rows without looping and logical indexing?
% your tables: table1 = table; table1.var1 = [1; 1; 3; 3; 6; 1; 1; 3; 3; 6]; table1.var2 = [1; 2; 2; 3; 6; 1; 2; 2; 3; 6]; t...

2 months ago | 1

| accepted

Answered
imshow with a slider object is blocking my Button Down function
(It's difficult to reproduce the behavior you describe without having the .mlapp file and necessary data files.) Most likely, p...

2 months ago | 0

| accepted

Answered
Dynamic dashboard radio button options
Yes, you can have the SelectionChangedFcn of the first ('Category') button group delete and re-create the radiobuttons of the se...

2 months ago | 0

Answered
Using clc in my simple scipt prevents user input question being displayed
The behavior you describe happens for me only in MATLAB Online. You can include a short pause after clc to get the input prompt ...

2 months ago | 0

| accepted

Answered
writetable/readtable with multi-line headers
Here's one way: % specify the file to write to output_file = 'test.csv'; % construct the table T = table(["Blue";"Red";"Gr...

2 months ago | 0

| accepted

Answered
Changing Plot colors while using fitlm
LinearModel.plot() does not allow you to specify line properties, but you can modify them after they are plotted. Here's an exa...

3 months ago | 1

Answered
name each legend with Yticklabel
In general, you'll need to modify all the legend calls, but for this particular .mseed file, the only adjustment to rdmseed.m yo...

3 months ago | 0

| accepted

Answered
When plotting functions like 1/sin(x), how can I remove the vertical lines at the points of discontinuity?
x = linspace(-2*pi,2*pi,1000); y = 1./sin(x); figure % put NaNs where y changes sign: y_plot = y; y_plot([false diff(sign...

3 months ago | 0

Answered
Assigning vectors to a list of names
vectors = "name"+(1:5) Given that string array of names, rather than creating a variable for each name, you can create a scalar...

3 months ago | 0

| accepted

Answered
Put a single legend on a 2D vector plot
[Note: I think you meant to transpose rayon_vect_x and rayon_vect_y in the first plot() call (so as to create 43 lines instead o...

4 months ago | 0

Answered
How to plot the temperature unit which is small circle raised at the left of C upper case?
In order to have '\circ' be rendered as the degree symbol in a text object's String, the text object's Interpreter must be 'late...

4 months ago | 1

Answered
Box charts move positions when applying the colour function
First I'll construct a table T similar to your table CB5_16B_FilteredData (except without the 'Salinity_Cla' column because for ...

4 months ago | 0

Answered
How to save numerous variables from different files in a csv in a for loop
writetable(T, 'FinalUSVData.csv', 'WriteMode', 'append') https://www.mathworks.com/help/matlab/ref/writetable.html#btyc9ne-1_se...

4 months ago | 1

Answered
Copy/Paste from ListBox at runtime
You can use the clipboard function. You'd have to implement any context menu or ctrl+c behavior. An example using a context me...

4 months ago | 0

Answered
trying to make a new array that is the sum of the previous entry for an unknown length
history = [1 2 3 4]; One way: n = length(history); playVal = zeros(1,n); if n > 0 playVal(1) = history(1); for cou...

4 months ago | 0

| accepted

Answered
Confusion in matrix multiplication
spectrum_normalized is a matrix (I know that because subplot(2,4,2) contains many lines). Thus, to plot the one-sided spectrum, ...

4 months ago | 1

| accepted

Load more