Answered
Value dependant sort of matrix rows
sorted_M8=M8'; sorted_M8(ismember(M8',8))=M8(:,1); sorted_M8=sorted_M8'; sorted_M8(:,1)=8;

3 days ago | 0

| accepted

Answered
Need help with plotting a complicated for loop
function y=f(x) for i=x if i>2 y=x.^2;%you are reassigning y every iteration, your y will be ...

4 days ago | 0

| accepted

Answered
How can I eliminate the NaN?
x = input('Angle in Radians:'); d=cos(x); f=1; difference = d - f; difference = abs(difference); threshold = .0001; n = 0;...

4 days ago | 0

| accepted

Answered
Typing a long and complicated equation
z=@(y)2*pi*(sqrt((44.56-y)/.16)+1).*sqrt(1+(1./(.32-.32*(sqrt((44.56-y)/.16)+1))).^2); y=0:.01:10;%have no idea what you are in...

4 days ago | 0

Answered
For loop for this ?
A simple matrix would work much better. Vcd=125*(ones(3,10).*[1.2,1.3,1.4]').^(1:10);%this is 10 years, each column with the di...

4 days ago | 0

Answered
bisection method with log
Once you graph your function, you see there are 4 roots. Using the bisection method to find the numerical roots should now be ea...

4 days ago | 1

Answered
How do put the values within a cell in a matrix?
dff1=wholedff{1}; dff2=wholedff{2}; ... but why would you want to do that? That is why we do indexing so we do not have to ha...

4 days ago | 0

Answered
Simpson's 1/3 Rule Implementation Issue (Code Provided)
The following function might help. function o = simp(a,b,f,n) x=linspace(b,a,n+1); o=0; for k=1:n xx=[x(k);(x(k)+x(k+1)...

5 days ago | 0

Answered
Setting variable names inside function based on input arguement in MATLAB
function ans=testNum(z) str = ''; NaN; while isnan(ans) input([str, 'Enter a value for ',z,': ']); ...

5 days ago | 0

| accepted

Solved


ZigZag - 01
Given a matrix, return the elements that are on the Z form of the matrix. For example - a=[1,2,3; 4,5,6; 7,8,9] ...

5 days ago

Solved


Seconds
Given the number of seconds after 12 am, find the time in the given format (12/24). If the format is not mentioned, use 24-ho...

5 days ago

Answered
Are there any functions that will return the index of the last string in a cell of strings?
find(ismember(cell,'a'),1,'last');

5 days ago | 1

| accepted

Answered
Symbolic solution to a system of equations
syms a; [1,-1;2,-1]\[a;0];

5 days ago | 0

Answered
How can I add a column of data to a matrix
A1=[A1;b1];

5 days ago | 0

Answered
How do I call a script inside a function?
Why not just use functions? I only use scripts when I am working in the workspace. Unless you are going to call a function more ...

5 days ago | 0

Answered
Applying a string of user inputs within a while-loop
Recommend breaking while loop with if statement: while 1 angle=input(['Enter the angle of trajectory [degrees] : ']); ...

6 days ago | 1

Answered
Matrix dimensions must agree
Several problems I have noticed: a = 0.4; f = 10^6; w = 2*pi*f;%scalar no need for . I0 = 1; b = (0.4/2); mu0 = 4 * pi * 1...

6 days ago | 0

Answered
Sorting a large 3 column data set
If I understand you correctly, can you not just subtract off a constant from both x and y coordinates to reset them to where you...

6 days ago | 0

| accepted

Answered
How can i get the trigonometric function of cos and sin of a variable
Why are the users not entering numbers instead of character arrays? T1 = input('Introduce the value of Theta for row 1 = ');

6 days ago | 0

Answered
The kinetic energy of a moving car object is KE=1/2mv^2
function energy = KE(m,v) energy= %put your code here end

6 days ago | 0

| accepted

Answered
Functions and For Loops For Polynomials
Too bad you can't use polyval(). This might get you started. function e=evalPoly(p,a) x=1; e=0; for k=1:length(p) e=e+p...

6 days ago | 0

Answered
consider preallocating for speed
No for-loop needed. No preallocation needed here. theta_2=1:360; th_2=theta_2*pi/180;%you could use cosd() and not need to con...

7 days ago | 0

Answered
How would I divide a 206x1 double it into 5 equal sections and average the values
I am not exactly sure what you mean. If you have matrix (M -206x1) and you want to find the mean of different groupings, then: ...

7 days ago | 0

Solved


Pandigital Factors (Based on Euler 491)
A Pandigital Number is a number containing all of the digits from 0-9 inclusive, with the added stipulation that it does not hav...

7 days ago

Solved


Bouncy numbers
Inspired by Project Euler n°112. * * Working from left-to-right if no digit is exceeded by the digit to its left it is call...

7 days ago

Answered
Sum of series with a variable
I always like to look at what I am doing before solving. Numerially, it should be relatively easy to find the root. alpha = 0.5...

8 days ago | 0

| accepted

Answered
how can i convert the content of a character array to a variable name
Generally, you should not do what you are trying to do. One possible solution is to use a struct. xx='Helo'; myStruct.(xx)=mag...

8 days ago | 0

| accepted

Answered
loop function help please
x=-10:10; for k=1:length(x) if x(k)<0 f(k)=3*x^2+5*x-7; else f(k)=3*x+4; end end

8 days ago | 0

Answered
n number of 2x2 matricies to diagonal matrix
n = input('Input the number of elements:'); k = ((E * avg_area)/L); k_global=diag([k,repmat(k+k,1,n-1),k])+diag(repmat(-k,1,n...

8 days ago | 0

| accepted

Solved


Pandigital number n°3 (Inspired by Project Euler 32)
After Problem 2319 and 2320. An n-digit number is pandigital if it makes use of all the digits 1 to n exactly ONCE. For examp...

9 days ago

Load more