Student

Answered

How do you find the maximum number of row vectors with loop?

Hello, You can find the maximum number in a vector with a loop by keeping the largest value stored as you progress over all t...

How do you find the maximum number of row vectors with loop?

Hello, You can find the maximum number in a vector with a loop by keeping the largest value stored as you progress over all t...

3 years ago | 1

| accepted

Answered

Why am I not getting different values for the absolute value percent error?

Hello, I'll begin by explaining why you're getting the same value for both. First, you are creating vectors |y| and |y2| b...

Why am I not getting different values for the absolute value percent error?

Hello, I'll begin by explaining why you're getting the same value for both. First, you are creating vectors |y| and |y2| b...

3 years ago | 2

| accepted

Answered

Write a function fml(x) where given vector x returns first, middle and last. If the number of elements in the vector are even, middle should take the mean value of the innermost elements.

Hello, Let's take a look at your code, function [first, middle, last] = fml(x) %FML Returns the first, middle, ...

Write a function fml(x) where given vector x returns first, middle and last. If the number of elements in the vector are even, middle should take the mean value of the innermost elements.

Hello, Let's take a look at your code, function [first, middle, last] = fml(x) %FML Returns the first, middle, ...

3 years ago | 1

| accepted

Answered

identity matrix what am i doing wrong

Hello, I would recommend you watch a video or read an introduction to coding in MATLAB. They don't take too long and should g...

identity matrix what am i doing wrong

Hello, I would recommend you watch a video or read an introduction to coding in MATLAB. They don't take too long and should g...

3 years ago | 1

Answered

Is there a better way to perform a moving window of operations without using a for loop?

Hello, You can figure out a way to use vector notation, x = 1:100; y = sqrt(x(1:end-3).^2+x(4:end).^2); I ran thi...

Is there a better way to perform a moving window of operations without using a for loop?

Hello, You can figure out a way to use vector notation, x = 1:100; y = sqrt(x(1:end-3).^2+x(4:end).^2); I ran thi...

3 years ago | 1

| accepted

Answered

Finding Characters place in a string by number of characters

Hello, You should be able to modify only columns 16 to 25 of that specific line with the following, fd = fopen('yourfile...

Finding Characters place in a string by number of characters

Hello, You should be able to modify only columns 16 to 25 of that specific line with the following, fd = fopen('yourfile...

3 years ago | 0

Question

MATLAB ode113 Not Evaluating Events Function?

Hello, I've worked with ode events in MATLAB many times now; however, I can't seem to figure out why the following events fun...

3 years ago | 1 answer | 0

Question

Interp3 Producing Unexpected Output?

Hello, When using the default trilinear interpolation of interp3, I'm getting an unexpected output: >> Interpval = inter...

3 years ago | 1 answer | 0

Answered

Odd (\\\r\n) output from symbolic multiplication

Hello, If it's just a one-timer, you can identify where it is and remove it by: expr = [expr(1:before) expr(after:end)];...

Odd (\\\r\n) output from symbolic multiplication

Hello, If it's just a one-timer, you can identify where it is and remove it by: expr = [expr(1:before) expr(after:end)];...

3 years ago | 1

Answered

created a function that inputs coordinate points like (1,2) in a loop for n number of points and keeps the x and y in seperate arrays. problem is it is only taking the first numbers entered... any clues?

Hello, Your code will work with one simple change: function[x,y] = readCoordinates(n) x = zeros(n,1); y ...

created a function that inputs coordinate points like (1,2) in a loop for n number of points and keeps the x and y in seperate arrays. problem is it is only taking the first numbers entered... any clues?

Hello, Your code will work with one simple change: function[x,y] = readCoordinates(n) x = zeros(n,1); y ...

3 years ago | 0

Submitted

imagesc3

Imagesc3 is a simple implementation of imagesc for 3D matrices.

3 years ago | 1 download |

Answered

Creation of vectors in for loop and save those and fill vector up with new column vectors

Hello, This can indeed be done: V = []; for ... A = [...]; B = [...]; V = [V A B]; end Hope t...

Creation of vectors in for loop and save those and fill vector up with new column vectors

Hello, This can indeed be done: V = []; for ... A = [...]; B = [...]; V = [V A B]; end Hope t...

3 years ago | 0

| accepted

Answered

Need help plotting a set of differential equations.

Hello, You can use the built-in |ode45| function to solve this: clear all close all clc % % Initialize time ...

Need help plotting a set of differential equations.

Hello, You can use the built-in |ode45| function to solve this: clear all close all clc % % Initialize time ...

3 years ago | 1

| accepted

Answered

How to Stop an M File?

Hello, You can use |return| in your script and function to exit. For example, function output = blah(input) if...

How to Stop an M File?

Hello, You can use |return| in your script and function to exit. For example, function output = blah(input) if...

3 years ago | 1

| accepted

Answered

Finding a significant difference between two datasets

Hello, Given data vectors |a| and |b| of equal length, you can use the following (assuming your x values are the default 1,2,...

Finding a significant difference between two datasets

Hello, Given data vectors |a| and |b| of equal length, you can use the following (assuming your x values are the default 1,2,...

3 years ago | 0

| accepted

Answered

How can I extract the white pixels of an image?

Hello, Assuming your image is of size m |x| n |x| 3, where the stored values range up to 255, you could use the following sim...

How can I extract the white pixels of an image?

Hello, Assuming your image is of size m |x| n |x| 3, where the stored values range up to 255, you could use the following sim...

3 years ago | 0

Answered

How to sort a matrix in matlab

Hello, The |sort| function can do this for you, % Given your A - first column: A = [50 0 10 0 0 0 0 30 0 0 1...

How to sort a matrix in matlab

Hello, The |sort| function can do this for you, % Given your A - first column: A = [50 0 10 0 0 0 0 30 0 0 1...

3 years ago | 0

Answered

Script writing: using the "for loop" in matrices?

Hello, You can use a |for| loop to fill in the elements of a matrix. In your case, you are dealing with a 1 x 100 matrix, whi...

Script writing: using the "for loop" in matrices?

Hello, You can use a |for| loop to fill in the elements of a matrix. In your case, you are dealing with a 1 x 100 matrix, whi...

3 years ago | 0

Answered

How to count the given data range and calculate cumulative sum of given data and plot it?

Hello, If I understand your question correctly, then this might help: data = xlsread('data.xls'); sf = (0:.5:2.5)'; ...

How to count the given data range and calculate cumulative sum of given data and plot it?

Hello, If I understand your question correctly, then this might help: data = xlsread('data.xls'); sf = (0:.5:2.5)'; ...

3 years ago | 0

| accepted

Answered

Error when using the function ODE45

Hello, You just need to change a few things: *Script* - missing an @ symbol. x_interval=[0.5 10]; t0 = 0; [x,t] = o...

Error when using the function ODE45

Hello, You just need to change a few things: *Script* - missing an @ symbol. x_interval=[0.5 10]; t0 = 0; [x,t] = o...

3 years ago | 0

| accepted

Answered

How do I present my solutions?

Hello, You could write a simple function, function printToAidanSheksDesires(A) fprintf('\nA = \n\n') fpr...

How do I present my solutions?

Hello, You could write a simple function, function printToAidanSheksDesires(A) fprintf('\nA = \n\n') fpr...

3 years ago | 1

Answered

Concatenate structure with subfields

Hello, Hopefully I understand your question properly. You can concatenate them with: data = [datarun1; datarun2; ......

Concatenate structure with subfields

Hello, Hopefully I understand your question properly. You can concatenate them with: data = [datarun1; datarun2; ......

3 years ago | 0

Answered

How to delete a row of a matrix if value in a particular column is less than a specified value?

Hello, You can use this one liner, datanew = data(data(:,1)>=4,:); However, I chose to reverse the logic here, so ins...

How to delete a row of a matrix if value in a particular column is less than a specified value?

Hello, You can use this one liner, datanew = data(data(:,1)>=4,:); However, I chose to reverse the logic here, so ins...

3 years ago | 0

| accepted

Answered

how can i plot this function p(Q,O)= sqr((sin(2*pi*sinQ*sinO)/(sin((pi/2)*sinQ*sinO))

Hello, To answer your original question, you can plot your function using a newer command called |fsurf|, fsurf(@(Q,O) s...

how can i plot this function p(Q,O)= sqr((sin(2*pi*sinQ*sinO)/(sin((pi/2)*sinQ*sinO))

Hello, To answer your original question, you can plot your function using a newer command called |fsurf|, fsurf(@(Q,O) s...

3 years ago | 0

Answered

Find the sum of the first n

Hello, This can be done simply with, n = 100; % whatever you want sum_harm = 0; for i = 1:n sum_harm = sum_h...

Find the sum of the first n

Hello, This can be done simply with, n = 100; % whatever you want sum_harm = 0; for i = 1:n sum_harm = sum_h...

3 years ago | 0

Answered

Running a simulation with different parameters on each loop

Hello, Kaushik Lakshminarasimhan was correct, |for| |loops| will check all options: for nPV = 1:10 for nW = 1:2 ...

Running a simulation with different parameters on each loop

Hello, Kaushik Lakshminarasimhan was correct, |for| |loops| will check all options: for nPV = 1:10 for nW = 1:2 ...

3 years ago | 1

| accepted

Answered

please explain the working of 2nd ,3rd and 4th statements of this coding portion:

Hello, This code checks to see if the diagonal elements of a given matrix A (assuming n x n) are larger in magnitude than th...

please explain the working of 2nd ,3rd and 4th statements of this coding portion:

Hello, This code checks to see if the diagonal elements of a given matrix A (assuming n x n) are larger in magnitude than th...

3 years ago | 2

| accepted

Answered

How can I end a for loop with an if or while loop

Hello, Yes you can end a for loop early using |break|, for N = 1:n % Do something if (some condition is met)...

How can I end a for loop with an if or while loop

Hello, Yes you can end a for loop early using |break|, for N = 1:n % Do something if (some condition is met)...

3 years ago | 0

| accepted

Answered

How to draw an animated line using my data?

Hello, In this scenario, I'd recommend just plotting the line every step as the line develops. You can do this by recordin...

How to draw an animated line using my data?

Hello, In this scenario, I'd recommend just plotting the line every step as the line develops. You can do this by recordin...

3 years ago | 1

| accepted

Answered

How to plot a quadratic equation?

Hello, If you have a newer release of Matlab (I believe R2016b), you can use the new <https://www.mathworks.com/help/matlab/r...

How to plot a quadratic equation?

Hello, If you have a newer release of Matlab (I believe R2016b), you can use the new <https://www.mathworks.com/help/matlab/r...

3 years ago | 4

| accepted