Answered
Monte carlo simulation code/ unreasonable results in averaging.
Very confusing code. function [br]= Rate_optimum(k) PL=3; N=10^5; MM=3; si=1; PT=10.^(5./10); PR=10.^(0./10); sign=10.^...

5 years ago | 0

Answered
solve x as function of y
y=10:100;%whatever y values you want [50 60 70 90 97.5] for k=1:length(y) eqn=@(x)100*(-8.5322289e3.*x + 2.1214010e3*x.^2 ...

5 years ago | 0

Answered
use the mat2cell function
b=mat2cell(a,[1 1 1 1 1],[[10 10], [10 10], [10 10], [10 10], [10 10]]);

5 years ago | 0

Answered
Reshaping a matrix into column
a=yourmatrix'; newVector=a(:);

5 years ago | 0

| accepted

Answered
Extract every 10th value from the excel file and save into new file
a=readmatrix('Book1.csv'); b=a(10:10:end,:); writematrix(b,'Book2.csv');

5 years ago | 1

| accepted

Answered
String and number please
a ='mosul42city6'; b=regexp(a,'\d'); count=length(b); num=a(b)-'0';

5 years ago | 0

Answered
Help executing calculation in for loop
myalpha=-43.43:1:43.43; for k=1:length(myalpha) FDC(k)=round((W.*dW)/cosd(myalpha(k))./dCB,3);%I am assuming that W, dW, and...

5 years ago | 0

| accepted

Answered
Looping through excel data till a specific amount of rows
a=readmatrix('yourfileName'); for k=1:3 figure; plot(a(25*(k-1)+1:25*k,1),a(25*(k-1)+1:25*k,2),a(25*(k-1)+1:25*k,1),a(25*...

5 years ago | 0

| accepted

Answered
Finding a centre and plotting a sphere
M=0;%point sets p and q assumed to be in matrix form, for example [1 2 3;4 5 6] for k=1:size(q,1) [m,idx]=max(sqrt(sum((p-...

5 years ago | 0

| accepted

Answered
How to loop over a range of values?
Why not store in a matrix? x = nan(n, 7); for r = 1:n x(n,:) = y'; end If not you could just: x = nan(7*n, 1); for r ...

5 years ago | 0

| accepted

Answered
Sum of array elements in A, that match entries in B
arrayfun(@(x)nnz(ismember(B,x)),A)

5 years ago | 0

| accepted

Answered
Newton Raphson to find intersection of graphs
Why not just use fzero() f=@(x)1+cos(x); g=@(x)sin(x); h=@(x)1+cos(x)-sin(x); interval=fzero(h,1)-fzero(h,-5); p=sort([fzer...

5 years ago | 0

Solved


Round the chord length!!

5 years ago

Solved


STOP that car!!!!!!

5 years ago

Solved


rotate the vector 270 degrees?

5 years ago

Answered
Distance between a point(x,y,z) and a surface(X,Y,Z)
Seems like a math question rather than a Matlab question. The minnum distance between a plane and a point is just the absolute v...

5 years ago | 1

Answered
Solving 1 equation with 1 unknown
a=-0.5:0.1:0.5; for k=1:length(a) eqn=@(M)(125/216)*((1+0.2*(M.^2)).^3)./M-a(k); sol(k)=fzero(eqn,1); end plot(a,so...

5 years ago | 0

Answered
How to get average of certain cells in a three dimensional table?
Average price of stock each month. stockA=zeros(1,61); stockB=zeros(1,61); for k=1:61 stockA(k)=mean(yourMatrix(k,1,:)); ...

5 years ago | 1

Answered
how to compute the mean value of non-zero elements in each row of a sparse matrix
a=C; a(a==0)=nan; mean(a,2,'omitnan');

5 years ago | 0

Answered
Timeseries events - how to extract y values for each event
I am assuming you have two arrays, t and y, of the same length. To get the y values corresponding to an array of input times, T,...

5 years ago | 0

| accepted

Answered
How to count the frequency of each type of column vector present in a matrix
R=[1,1,1,2,2,2,1,2,2,1,4,2,2,2,2,1,2,1,3,1,1;1,1,2,2,2,1,2,2,1,4,2,2,2,2,1,2,1,3,1,1,1;1,2,2,2,1,2,2,1,4,2,2,2,2,1,2,1,3,1,1,1,1...

5 years ago | 0

| accepted

Answered
How to get this into a loop
x=rand(1,20); for k=1:19 h(k)=x(k+1)-x(k); end Or without loop x=rand(1,20); h=diff(x);

5 years ago | 0

| accepted

Answered
re-arrange data
Output will have to be a cell array. Input= {'A','B1','X6(1.4M), X15(3M), X25(5M), X50(10M), X75(15M), X100(20M)',' X6~0, X15~...

5 years ago | 0

Answered
gpa calculator with matrix
Why not just input the matrix? m=input('matrix of grades and units, for example [3.5,4;2.7,2;4.0,3;3.3,2]'); gpa=sum(prod(m,2)...

5 years ago | 0

Answered
Make spceficic array values zero.
a=find(diff(isnan(Input))==1); b=find(Input==-1); Output=zeros(size(Input)); for k=a Output(b(find(b<=k,1,'last')))=-1; ...

5 years ago | 1

| accepted

Solved


Reverse your name ?

5 years ago

Answered
Need Help Creating a loop
m = randi([5,15]); n = randi([5,15]); mat=zeros(m,n); for row=1:m for col=1:n mat(row,col)=(row+col)/col^2; ...

5 years ago | 0

Answered
replace maximum values of each row of a matrix
B=A==max(A,[],2);

5 years ago | 1

| accepted

Load more