Answered
Open all CSV files in a folder and then label using original file names
I'm not sure what you mean by "name all the variables after their original name", but you'll want to use brace indexing for stor...

4 years ago | 0

Answered
Making plot markers distinct
x = 1:11; y = [4.89 4.68 4.54 4.62 4.63 4.95 5.24 5.32 5.21 5.17 5.08]; plot(x,y,'-o'); hold on idx = 5:8; plot(x(idx),y(id...

4 years ago | 1

| accepted

Answered
I am having a hard time running my code. I do not know what I am doing wrong. How can I fix it.
Five things: 1) use the 's' option with input() if you want to take the user input exactly as it is (i.e., a character vector) ...

4 years ago | 0

Answered
How to output the answer to a while loop into an array
Maybe this is what you are going for: h(1) = 1; hnew = h/2; while hnew >= 1e-13 h(end+1) = hnew; hnew = h(end)/2; ...

4 years ago | 0

Answered
In the following MATLAB program, I am trying to find how many times that a face cards are drawn from a deck of 52 poker cards when I draw a card, replace it, and reshuffle.
You've got the inputs to ismember() backwards; you are counting the number of (unique) face cards drawn, rather than the number ...

4 years ago | 0

| accepted

Answered
Creating a code to solve quadratic equation
How about applying the quadratic formula? Is that allowed? % a*t^2+b*t+c = 0 d = sqrt(b^2-4*a*c); t1 = (-b+d)/(2*a); t2 = (-...

4 years ago | 0

| accepted

Answered
Elementary matrices in Matlab
Here's one way you can do it (and it produces the correct matrix too): N = 10; R = zeros(N); R(2:N+1:end-N) = 2; R(3:N+1:end...

4 years ago | 0

Answered
where to write function
Sorry, I had the impression that the question was where to write the function, based on the title, "where to write function". I...

4 years ago | 0

| accepted

Answered
How to save mat file in Matlab
This will generate 10 mat files, 9 of which contain a 1024x1 variable of contiguous samples from your original mat file and 1 of...

4 years ago | 0

| accepted

Answered
How to change the angle of xticklabel?
You can use set(gca(),'XTickLabelRotation',0); To demonstrate: figure(); plot(1:10); set(gca(),'XLim',[1 10],'XTick',1:0.5:1...

4 years ago | 0

| accepted

Answered
Break X-axis in Matlab
Maybe an approach like this would work: x = -20:0.1:20; xtl = [-18 -16 -14 14 16 18]; xlim = [-19 -13; 13 19]; gap_size = 0....

4 years ago | 3

Answered
Can someone help me with this error? Im looking to also plot x,f(x)
f(x) in that context is the xth index of f. Indices must be positive integers (or logicals - don't worry about it if you don't k...

4 years ago | 0

Answered
Getting error: "Undefined function 'tauchen' for input arguments of type 'struct'."
Yes, it looks like you're missing a function called "tauchen", or maybe you have it somewhere but it's not on the MATLAB path. H...

4 years ago | 0

Answered
Hi I'm trying to plot using a for loop. don't see syntax errors but plot comes out empty. appreciate your guidance.
The plot comes out empty because you're only plotting the last point. Try it like this: t = 0:30/100:30; y1 = 6*exp(-0.2)*t.*s...

4 years ago | 0

| accepted

Answered
reading data by column
If you have an n-by-m matrix you can do as follows: n = 100; m = 50; data = randn(n,m); results = cell(1,m); for jj = 1:m...

4 years ago | 0

| accepted

Answered
How can I find horizontal Seams ?
You may not have to change the code at all. Have you tried transposing the input before passing it to the function and then tran...

4 years ago | 0

Answered
Use vector input to anonymous function and append output to a vector (to plot the results).
Use "./" rather than "/" in your calculation of FWD, in order to do element-wise division. % clear the command window, workspac...

4 years ago | 0

| accepted

Answered
How to identify first local minima before the main peak?
I think the problem is that there is an implicit assumption in your code about whether the i-th peak comes before the i-th troug...

4 years ago | 0

| accepted

Answered
how can I only display all the data?
If your version of MATLAB is R2019a or newer, you can use readmatrix(): filename = 'DHD_10%_sec_T1.txt'; data = readmatrix(fil...

4 years ago | 0

| accepted

Answered
need to read a mixed csv file
Try this. It will create a struct (called 'vars') with fields corresponding to the variables you specified. (If you really want ...

4 years ago | 0

| accepted

Answered
How to display the legend for data of an empty table (0 x 11)?
You can check if each table variable is empty and if it is plot a NaN point instead. The point won't show up, but the line objec...

4 years ago | 0

| accepted

Answered
How to continue a count from the previous when calling each function? Attached photo explains further.
There are a few ways you could do this. Probably the easiest would be to remove the time calculation from Line.m and Point.m and...

4 years ago | 0

| accepted

Answered
Update struct field in parfor
I don't know whether it's feasible in your actual code, but you might try making method an array of structs and accessing one el...

4 years ago | 0

| accepted

Answered
Running Matlab in Parallel on local machine or another suggestion
You've got 2 nested for loops there, the outer one looping over all the F.* files and the inner one looping over all the Narepli...

4 years ago | 2

Answered
How do I create this matrix?
You're on the right track with diag(), but you need to concatenate the 4 blocks together (you can use ones() (among other functi...

4 years ago | 1

| accepted

Answered
Plot geographic data with DMS labels on y-axis
Something like this would work: errorbar(1:7, 40.00785+0.00001*randn(1,7), 0.00001*randn(1,7), '.', 'Color', 'k', 'MarkerSize',...

4 years ago | 0

| accepted

Answered
How do I create this diagonal matrix?
diag(1:5:396)+5

4 years ago | 1

| accepted

Answered
How can i use a for loop based on a row value
a = 100; b = 200; c = 300; d = 101; e = 201; f = 301; g = 102; h = 202; i = 302; j = 103; k = 203; l = 303; A = [ ... ...

4 years ago | 0

| accepted

Answered
How to plot 3d mesh surface?
See below for various changes, including the one you asked about. %Part A % a)plot graph solar declination versus the day numb...

4 years ago | 0

| accepted

Answered
How to tabulate?
You do not need to interpolate because the dn values you want the sdelta for are all already in the vector of all dn values (i.e...

4 years ago | 0

Load more