MATLAB Enthusiast.

Chemical Engineering Student; interested in computation and modelling.

Enjoys Snowboarding.

Question

How can I make this code more efficient?

Hello, Because of the large number of differential equations I'm trying to solve, I would like to make this code more efficie...

plus de 5 ans ago | 1 answer | 0

Answered

X and Y matrix of size:1x68.this code works well.but when command " plot(X,Y,'ro', x,y,'-b',xt,yt,'--g');" shifted outside for loop; plot for last value of xt and yt How to store all values of xt and yt outside for loop?

Change the the lines to: xt(i,:) = X0+(0.1*(max(X)-min(X))*[-1 0 1]); and yt(i,:) = y(k) + m(k)*(0.1*(max(X)-min(...

X and Y matrix of size:1x68.this code works well.but when command " plot(X,Y,'ro', x,y,'-b',xt,yt,'--g');" shifted outside for loop; plot for last value of xt and yt How to store all values of xt and yt outside for loop?

Change the the lines to: xt(i,:) = X0+(0.1*(max(X)-min(X))*[-1 0 1]); and yt(i,:) = y(k) + m(k)*(0.1*(max(X)-min(...

presque 7 ans ago | 0

Answered

Cubic spline interpolation with second derivative at ends as zero

Doesn't the <http://www.mathworks.com/help/matlab/ref/spline.html spline> function work?

Cubic spline interpolation with second derivative at ends as zero

Doesn't the <http://www.mathworks.com/help/matlab/ref/spline.html spline> function work?

presque 7 ans ago | 0

Answered

i want some links to basic matlab problem solving

The <http://www.mathworks.com/matlabcentral/cody/?s_tid=gn_mlc_cody cody> problems give some quick practice.

i want some links to basic matlab problem solving

The <http://www.mathworks.com/matlabcentral/cody/?s_tid=gn_mlc_cody cody> problems give some quick practice.

presque 7 ans ago | 0

| accepted

Answered

How i save the value of c in deach loop and sum these value after each value then using value in another eq outside loop??

Say E=3; for i=1:3 A(i)=x((i-1)*3+1); B(i)=x((i-1)*3+2); C(i)=x((i-1)*3+3); Z(i)=A*B+C*A; W=E-sum(C); end

How i save the value of c in deach loop and sum these value after each value then using value in another eq outside loop??

Say E=3; for i=1:3 A(i)=x((i-1)*3+1); B(i)=x((i-1)*3+2); C(i)=x((i-1)*3+3); Z(i)=A*B+C*A; W=E-sum(C); end

presque 7 ans ago | 0

Answered

How do I stack many files together into one?

One way of doing this name='SpectraA' for i=1:5 #Let's say you have SpectraA1....SpectraA5 Filename=strcat(name, num2str(...

How do I stack many files together into one?

One way of doing this name='SpectraA' for i=1:5 #Let's say you have SpectraA1....SpectraA5 Filename=strcat(name, num2str(...

presque 7 ans ago | 0

Answered

matlab exe file to run as admin

Do you have the shortcut? You can right click --> Properties --> Location and find it. Even there, you can right click the short...

matlab exe file to run as admin

Do you have the shortcut? You can right click --> Properties --> Location and find it. Even there, you can right click the short...

presque 7 ans ago | 0

Answered

what's the program mistake?

Try this? clear all clc; syms x A=[x 2 1;1 0 -x;5 1 x]; b=det(A) r=eval(solve(b==0))

what's the program mistake?

Try this? clear all clc; syms x A=[x 2 1;1 0 -x;5 1 x]; b=det(A) r=eval(solve(b==0))

presque 7 ans ago | 0

Answered

How to make loop and sum the result ??

for i=1:3 A(i)=x((i-1)*3+1); B(i)=x((i-1)*3+2); C(i)=x((i-1)*3+3); R(i)=A^2+B^3+A*c; end Summation=sum(C);

How to make loop and sum the result ??

for i=1:3 A(i)=x((i-1)*3+1); B(i)=x((i-1)*3+2); C(i)=x((i-1)*3+3); R(i)=A^2+B^3+A*c; end Summation=sum(C);

presque 7 ans ago | 0

| accepted

Answered

Vector indexing inefficiency question.

Have you looked at <http://www.mathworks.com/help/matlab/ref/perms.html perms> built-in function? I'm sure you can manipulate to...

Vector indexing inefficiency question.

Have you looked at <http://www.mathworks.com/help/matlab/ref/perms.html perms> built-in function? I'm sure you can manipulate to...

presque 7 ans ago | 0

| accepted

Answered

I face the error of "In an assignment A(I) = B, the number of elements in B and I must be the same" when i want to create a loop a matrix. my simple short code given below, plz help me?

p(i) is one element, but you are trying to tell it to store multiple values, one of the following would fix your problem (Just r...

I face the error of "In an assignment A(I) = B, the number of elements in B and I must be the same" when i want to create a loop a matrix. my simple short code given below, plz help me?

p(i) is one element, but you are trying to tell it to store multiple values, one of the following would fix your problem (Just r...

presque 7 ans ago | 0

| accepted

Answered

Extract a row of multiple files in loop

I didn't look through the whole code, but based on the error, try the following: line(i) =line(i)+Signal(pixel_line,:); ...

Extract a row of multiple files in loop

I didn't look through the whole code, but based on the error, try the following: line(i) =line(i)+Signal(pixel_line,:); ...

presque 7 ans ago | 0

| accepted

Answered

Reading specific Cell in Excel

Have you looked at the <http://www.mathworks.com/help/matlab/ref/xlsread.html xlsread> documentation? It tells you exactly how t...

Reading specific Cell in Excel

Have you looked at the <http://www.mathworks.com/help/matlab/ref/xlsread.html xlsread> documentation? It tells you exactly how t...

presque 7 ans ago | 1

Answered

Extract xdata and ydata from hggroup

If you have the .fig file, you can just follow this <http://www.mathworks.com/matlabcentral/answers/100687-how-do-i-extract-data...

Extract xdata and ydata from hggroup

If you have the .fig file, you can just follow this <http://www.mathworks.com/matlabcentral/answers/100687-how-do-i-extract-data...

presque 7 ans ago | 0

Answered

How to make a vector where each element=5 and 100 elements long?

What you did produces a vector that starts at 1 and goes up by 5 till it reaches 100 elements. If that was your goal, then it's ...

How to make a vector where each element=5 and 100 elements long?

What you did produces a vector that starts at 1 and goes up by 5 till it reaches 100 elements. If that was your goal, then it's ...

presque 7 ans ago | 0

Question

Why is 10^5 more expensive than 10e5?

As Jan mentioned in this <http://www.mathworks.com/matlabcentral/answers/57638#comment_119764 post>, what's the reason behind it...

presque 7 ans ago | 1 answer | 1

Answered

i need to fix errors in interface

This line: filename('waad s.jpg') is not a valid code to put into MATLAB. I am not sure what you're trying to do, but th...

i need to fix errors in interface

This line: filename('waad s.jpg') is not a valid code to put into MATLAB. I am not sure what you're trying to do, but th...

presque 7 ans ago | 0

Answered

change the number of digits after decimal point

You can use the <http://www.mathworks.com/help/matlab/ref/sprintf.html sprintf> or the <http://www.mathworks.com/help/matlab/ref...

change the number of digits after decimal point

You can use the <http://www.mathworks.com/help/matlab/ref/sprintf.html sprintf> or the <http://www.mathworks.com/help/matlab/ref...

presque 7 ans ago | 0

| accepted

Answered

plot multipe figures with diferents color

You can iterate through each point with a for loop ColoursToUse=['r' 'b' 'g' 'c'] figure(1) hold on for i=1:4 plot3(mx(...

plot multipe figures with diferents color

You can iterate through each point with a for loop ColoursToUse=['r' 'b' 'g' 'c'] figure(1) hold on for i=1:4 plot3(mx(...

presque 7 ans ago | 0

Answered

how can I direct a user to the script end script skipping intermediate?

You can easily just add an if statement for the code to only apply based on what you input into it. For example, let's say I hav...

how can I direct a user to the script end script skipping intermediate?

You can easily just add an if statement for the code to only apply based on what you input into it. For example, let's say I hav...

presque 7 ans ago | 0

Answered

Generation of random numbers

I think what you're trying to do is done using randn, so that dd=(10^(4) - 10^(-4)).*randn(1000,1) + 10^(-4) hist(dd,100...

Generation of random numbers

I think what you're trying to do is done using randn, so that dd=(10^(4) - 10^(-4)).*randn(1000,1) + 10^(-4) hist(dd,100...

presque 7 ans ago | 0

| accepted

Answered

what 's different between axis square and axis equal in matlab ?

From this <http://www.mathworks.com/help/matlab/ref/axis.html page>: axis equal sets the aspect ratio so that the data units ...

what 's different between axis square and axis equal in matlab ?

From this <http://www.mathworks.com/help/matlab/ref/axis.html page>: axis equal sets the aspect ratio so that the data units ...

presque 7 ans ago | 3

| accepted

Answered

I want to make a function with save option.

The problem is in the way you're handling the variables. Basically, the inputs to your function in this case are taken as variab...

I want to make a function with save option.

The problem is in the way you're handling the variables. Basically, the inputs to your function in this case are taken as variab...

presque 7 ans ago | 0

| accepted

Answered

How to use legend command

Is the loop still telling the figure to plot even if there isn't any data recorded? You have a few ways around it: The first...

How to use legend command

Is the loop still telling the figure to plot even if there isn't any data recorded? You have a few ways around it: The first...

presque 7 ans ago | 0

| accepted

Answered

How to plot multiple iterations on the same axes?

figure; hold on for i=1:length(s_x_index) f_value(i)=f_x # This is the value that you get from each iteration end plot(s_x...

How to plot multiple iterations on the same axes?

figure; hold on for i=1:length(s_x_index) f_value(i)=f_x # This is the value that you get from each iteration end plot(s_x...

presque 7 ans ago | 0

Answered

Convert a Roman numeral to its decimal equivalent for first ten roman numerals?

Have a look at this <http://www.mathworks.com/matlabcentral/fileexchange/26161-roman2num-and-num2roman--modern-roman-numerals fu...

Convert a Roman numeral to its decimal equivalent for first ten roman numerals?

Have a look at this <http://www.mathworks.com/matlabcentral/fileexchange/26161-roman2num-and-num2roman--modern-roman-numerals fu...

presque 7 ans ago | 0

Answered

How May I import date/time from Excel?

Have you looked at this <http://www.mathworks.com/matlabcentral/newsreader/view_thread/284903 solution>?

How May I import date/time from Excel?

Have you looked at this <http://www.mathworks.com/matlabcentral/newsreader/view_thread/284903 solution>?

presque 7 ans ago | 0

Answered

How come i get different output answers with the same matlab version, the same code installed on two different computers?

I am assuming that your problem is ill-conditioned or is very sensitive and depends greatly on the numbers from each step (or th...

How come i get different output answers with the same matlab version, the same code installed on two different computers?

I am assuming that your problem is ill-conditioned or is very sensitive and depends greatly on the numbers from each step (or th...

presque 7 ans ago | 0

| accepted

Answered

how to change matrix dimensions?

Based on what you told me, let's say that the data for the years 1984-2009 is stored in matrix A, you would simply do: B=A(...

how to change matrix dimensions?

Based on what you told me, let's say that the data for the years 1984-2009 is stored in matrix A, you would simply do: B=A(...

presque 7 ans ago | 0

| accepted

Answered

How to get image from axes in GUI matlab

After knowing which axes handle the image is loaded into, you can simple use the <http://www.mathworks.com/help/images/ref/getim...

How to get image from axes in GUI matlab

After knowing which axes handle the image is loaded into, you can simple use the <http://www.mathworks.com/help/images/ref/getim...

presque 7 ans ago | 1