Community Profile

photo

David Fletcher


Last seen: Today

De Montfort University

212 total contributions since 2018

Prior roles - technician (pharmaceutical chemistry, pharmacognosy and electron microscopy). Currently working as a senior technician in pharmaceutical technology.

David Fletcher's Badges

  • Introduction to MATLAB Master
  • 3 Month Streak
  • Knowledgeable Level 3
  • First Answer
  • CUP Challenge Master
  • Solver

View details...

Contributions in
View by

Answered
How to convert this ...for loop to while loop ?
i=1; while i<=5 j=1; while j<=20 amp=i*1.2; wt=j*0.05; v(i,j)=amp*sin(wt); j=j+...

22 hours ago | 1

| accepted

Answered
How to segment one row matrix into multiple row matrix
Ultimately you can't have a matrix of the segments since they are potentially of different lengths - you could have a cell array...

1 day ago | 0

Answered
How can I store the result after each iteration in a row vector?
A quick hack would be: Ad = [1 2]; Ac = [1 2 3 4]; As=[]; for i=1:length(Ac) for j=1:length(Ad) As=[As Ad(...

1 day ago | 0

| accepted

Answered
Plot doesn't show lines, only markers
In that case it would largely depend on your code, and how much effort you want to put into it (I assume this 'values' variable ...

1 day ago | 0

Answered
Plot doesn't show lines, only markers
Take a look at the help documentation for the plot command: https://uk.mathworks.com/help/matlab/ref/plot.html There are optio...

2 days ago | 0

Answered
How to build a table within an if loop without preallocation
Doubtless, you will kick yourself - but put your main table declaration outside the loop, or you'll be overwriting the old main ...

3 days ago | 0

| accepted

Answered
Save Monte Carlo output
Change the line ExpoStart(column)=row to ExpoStart(i,column)=row And (I think) it will do what you want. There is an argumen...

4 days ago | 0

| accepted

Answered
Save variable to .mat file
try this: save(strcat(Name,'_waviness'),'waviness')

5 days ago | 0

Answered
How to reference points in time in a matrix?
a=[ 0 0 0 0] a=[a; 0 0 0 0] a=[a; 0 0 0 0] a=[a; 0 0 0 0] a=[a; 0 ...

5 days ago | 0

| accepted

Answered
Identifying missing values in matrices
try idx=~ismember(B,A) C=A(idx)

5 days ago | 0

| accepted

Answered
load data cell from Mat file from Matlab file
clearvars; clc; ss=load('matlab_t.mat','unnamed'); %% I would like this to be ss=[1;2;3] ss=ss.unnamed

5 days ago | 0

Answered
How to make unfilled plot points?
Think you'll find it's due to the linewidth - change it to 1 and they shouldn't be filled. MarkerSize changes the size of the po...

6 days ago | 0

| accepted

Answered
rng() throwing error
Not really sure: only thing that springs to mind is something shadowing the Matlab function? what do get when you type: which ...

6 days ago | 1

| accepted

Answered
How to remove vectors values with restraints?
A = [ 0.1 0.2 0.4 0.6] B = [ 0.5 0.9 0.6 0.2] C=(A+B)<1 A=A(C) B=B(C) C = 1×4 logical array 1 0 0 ...

6 days ago | 0

Answered
How to save the results of all iterations?
Something like this? R=1.1/100; %m k=1; %W/m.K rho=1100; %kg.m^3 Cp=4180; %J/kg.K h=2700; %W.m^2.K ...

7 days ago | 0

| accepted

Answered
For Loop Indexing exceeding array elements
First run of the loop you are overwriting the z vector with a scaler if k <= 1 z=5; mu = 0; On...

7 days ago | 0

Solved


Create an n-by-n null matrix and fill with ones certain positions
The positions will be indicated by a z-by-2 matrix. Each row in this z-by-2 matrix will have the row and column in which a 1 has...

7 days ago

Solved


Calculate a Damped Sinusoid
The equation of a damped sinusoid can be written as |y = A.&#8519;^(-&lambda;t)*cos(2πft)| where |A|, |&lambda;|, and |f| ...

7 days ago

Solved


Solve a System of Linear Equations
*Example*: If a system of linear equations in _x&#8321_ and _x&#8322_ is: 2 _x&#8321;_ + _x&#8322;_ = 2 _x&#8321;...

7 days ago

Solved


Magic is simple (for beginners)
Determine for a magic square of order n, the magic sum m. For example m=15 for a magic square of order 3.

7 days ago

Solved


Make a random, non-repeating vector.
This is a basic MATLAB operation. It is for instructional purposes. --- If you want to get a random permutation of integer...

7 days ago

Solved


Number of 1s in a binary string
Find the number of 1s in the given binary string. Example. If the input string is '1100101', the output is 4. If the input stri...

7 days ago

Solved


Return the first and last characters of a character array
Return the first and last character of a string, concatenated together. If there is only one character in the string, the functi...

7 days ago

Solved


Getting the indices from a vector
This is a basic MATLAB operation. It is for instructional purposes. --- You may already know how to <http://www.mathworks....

7 days ago

Solved


Check if number exists in vector
Return 1 if number _a_ exists in vector _b_ otherwise return 0. a = 3; b = [1,2,4]; Returns 0. a = 3; b = [1,...

7 days ago

Solved


Generate a vector like 1,2,2,3,3,3,4,4,4,4
Generate a vector like 1,2,2,3,3,3,4,4,4,4 So if n = 3, then return [1 2 2 3 3 3] And if n = 5, then return [1 2 2...

7 days ago

Solved


Return area of square
Side of square=input=a Area=output=b

7 days ago

Solved


Maximum value in a matrix
Find the maximum value in the given matrix. For example, if A = [1 2 3; 4 7 8; 0 9 1]; then the answer is 9.

7 days ago

Answered
how to save the results obtained by a for loop repeated n times
AC = [100 2; 110 4; 105 3; 130 7; 120 5; 115 5; 115 3; 140 7; 110 9; 105 4; 110 3; 120 5 ]; A = 3; function [C] = Trend(A...

8 days ago | 0

| accepted

Answered
Multiplication of elements of matrix without using for loop
A.*B ans = 1.0000 1.0000 0.9999 0.2500 0.4000 0.4998 0.1400 0.2400 0.3333

8 days ago | 0

| accepted

Load more