Answered
File: laxexplicit.m Line: 41 Column: 31 Invalid expression. When calling a function or indexing a variable, use parentheses. Otherwise, check for mismatched delimiters.
There were some syntax errors in the calculation of u(i,k+1). I made a guess at fixing them. (And another syntax error in "Title...

4 years ago | 0

Answered
Dividing an entire row by every element of a column
Like this? (Using a 5x3 matrix as an example.) A = (1:5).'+3*(0:2) A(3,:)./A(:,1) % 3rd row divided by first column % 3/1 ...

4 years ago | 0

| accepted

Answered
Matlab Directory Stopped Finding File
Maybe yesterday when you ran this your working directory was "E:\Uni\Imaging\23-11\8\" and today it is "E:\Uni\Imaging\23-11\". ...

4 years ago | 0

| accepted

Answered
How to extract a field from a structure?
% making a struct array with two fields: S = struct('sample',num2cell(1:10),'info',sprintfc('information_%d',1:10)) % get the ...

4 years ago | 3

| accepted

Answered
How do create an excel sheet and have data uploaded with each iteration of a loop?
% initialize the results to all zeros: N_cases = 3; results = zeros(N_cases,3); % populate the "results" matrix: for ii = 1:...

4 years ago | 0

Answered
Resetting for loop counter
If the entire purpose of the for loop is to remove columns in tactarray that have any element less than 1, it can be replaced by...

4 years ago | 0

| accepted

Answered
How to write to a .xlsx file and include a variable value in its filename
k = 3; % for instance output_file_name = sprintf('values_trial_%d.xlsx',k) writecell(C,output_file_name,'Sheet',1,'Range','B...

4 years ago | 0

Answered
How to create a for loop for this?
No loop is necessary; you can use diff (see below). n = 4; startFrequency = 0.25; endFrequency = 1; frequencies = linspace(s...

4 years ago | 0

| accepted

Answered
I need a function or boucle
X = 1:10; M = []; idx = 1:numel(X); for ii = idx([end 1:end-1]) M = [M; X(idx ~= ii) X(ii)]; end disp(M);

4 years ago | 1

| accepted

Answered
Histogram plot by equal time intervals
clc A = load ('TutorialSampleT.txt'); Time = A (:,1) ; x = A (:,2 ) ; y = A (:,3 ) ; z = A (:,4 ) ; Amplitude = A (:,5) ; ...

4 years ago | 0

| accepted

Answered
Graphs with stacked plot
x=linspace(0,2*pi,100)'; y1=sin(x); y2=cos(x); y3=tan(x); stackedplot(table(x,y1,y2,y3),{{'y1' 'y2'} {'y2' 'y3'} {'y3' 'y1...

4 years ago | 1

| accepted

Answered
A function without any argument
There is a line in runKut5 that looks like it accidentally got commented out due to a comment on the previous line: if nargin <...

4 years ago | 0

| accepted

Answered
Combine block matrix with same elements
A = [7 7 2; 6 9 2; 6 8 8] repelem(A,[2 2 2],[2 3 2])

4 years ago | 0

| accepted

Answered
What is wrong with MATLAB asin() function.
Since both screen shots have the debugger stopped on line 5, it would appear that the value of ux is up to date but that thetad ...

4 years ago | 0

| accepted

Answered
How to plot loop items on legend
%range x = 50:1000; TL = zeros(length(x), 1); % memory pre-allocation fRat_all = [0.1, 0.15, 0.3]; % pre-allocate line h...

4 years ago | 1

| accepted

Answered
Removing entire column if any of the value in that column contains a NaN
% make a table with some NaNs: A = magic(5); A([7 15]) = NaN; t = array2table(A) % remove columns/table-variables with any N...

4 years ago | 0

| accepted

Answered
summation operation for a matrix?
x = (1:36)+(1:36).' % some 36-by-36 matrix % add first row and first column (exlcuding first element) sum(x(1,:))+sum(x(2:end,...

4 years ago | 0

| accepted

Answered
Standard deviation of columns of a table
Here's one way: data = num2cell(randn(30,3),1); montherrors = table(data{:}) stdev = std(montherrors{:,:},[],1)

4 years ago | 1

| accepted

Answered
Using Stair plot with a For loop and If statement for ranges
In each iteration of the for loop, t is a scalar. First t is 1, then 2, and so on until t is 50 in the last iteration. Now, afte...

4 years ago | 0

| accepted

Answered
how do plot a 3d plot, example like a water fall plot?
Try this: % first I make some variables with the same names % and sizes as yours, since I don't have yours: radiationx = (1:...

4 years ago | 0

Answered
How to label coordinates as sites from a 10x2 list of and x and y coordinates.
Something like this? x = [0.2; 0.7; 0.4; 0.6; 0.6; 0.3; 0.8; 0.3; 0.2; 0.1]; y = [0.2; 0.5; 0.5; 0.6; 0.7; 0.1; 0.2; 0.9; 0.7;...

4 years ago | 0

| accepted

Answered
How can I reshape the given file into excel file ?
Here's one way to do that: C = readcell('matlab.csv'); C = cellfun(@str2num,C,'UniformOutput',false); C(cellfun(@isempty,C)) ...

4 years ago | 1

Answered
File does not go into right folder
Looks like the train_labels you are getting from the first column of that xlsx file are all NaN (and NaN is not equal to 0 so th...

4 years ago | 0

| accepted

Answered
Comprehension of this command: Matrix(~any(Matrix, 2), :) = [];
The function any takes a condition as its first argument and an optional second argument that says which dimension(s) the condit...

4 years ago | 0

| accepted

Answered
Loop through csv file -- please help
Note that fgetl returns a character vector, so multiplying that by Tframe isn't what you mean to do. You can try converting that...

4 years ago | 0

| accepted

Answered
fplot giving a different graph than my graphing calculator
You can specify an interval in fplot, like you said, or you can specify the x- and/or y-limits of the axes after the plot is mad...

4 years ago | 0

| accepted

Answered
Write a random row vector x of size 1x10000. Find in the same for loop the number of elements of x that are btw 0.2 and 0.4.
The check for x(i) between 0.2 and 0.4 also has to be inside the for loop (or in its own separate for loop); otherwise you are o...

4 years ago | 1

| accepted

Answered
Element by element interpolation
A = ones(2) B = magic(2) A+B n = 3; for i = 0:n % i=0 -> C=A % i=n -> C=A+B C = A+B*i/n end

4 years ago | 0

| accepted

Answered
Index exceeds number of array elements
Actually those variables are scalars (only one element each): % after "altitude = 0.0;" the rest of the line has no effect: ...

4 years ago | 0

| accepted

Answered
Doesn't Match legend color and plot color
Your first plot call plots y0 vs x. y0 is a scalar and x is 1-by-60. Plotting these variables creates 60 lines, so when you make...

4 years ago | 1

Load more