In my project I basically need to plot 3D color coded surface graphs using MATLAB taking input from multiple .dat files (i have 1000 .dat files). In each file I have parameters x and y, and when I take multiple files, each having a different value of z, I can finally plot a graph. so does anyone...
I need to figure out how to create a matrix that has zeros in everything except the diagonal, and I need the diagonal to be random numbers from 1 to 5. I tried a few different variations like this:
R = eye(5)*7*randi(10,5)
But I keep ending up with values in every row and column and I am at a...
Hi,
I´m a complete MatLab noob and just started using it. I have a set of 30 timeseries measurements (so for a period of 100 years I have 30 measurements for every year, but some years do not have all 30 measurements) and I am trying to find the average of all possible pairs, triplets, etc...
Hey everyone. I want to extract numerical data from files let's say g0001.txt to g0060.txt and store it in a matrix with each element is an array.
like this:
M=[g1() g2() g3() ...g60()]
matrix order can be 1 x 60 , i.e. to say 1 row and 60 columns and each element is an array...
im in a scientific computing class, where we are using MATLAB to model harmonic oscillators and pendulums using like the euler method for ode's. We pretty much got shoved off the deep end with the programming side. I use google to look up things to help me. But its not working that well. What...
I'm trying to do a calculation which involves taking the derivative of a term that is millions of terms long. I'm using a supercomputer right now with Mathematica to do it but it's taking to long. Does Matlab have a faster algorithm for computing derivatives analytically?
i'm trying to learn MATLAB and as such i stumbled here while looking something up
http://www.mathworks.com/help/matlab/matlab_prog/floating-point-numbers.html
so the questions is
how does someone avoid something like
e = 1 - 3*(4/3 - 1) (this is example 1 in the webpage above)
not...
Hi,
I'm trying to write a code for the recursive trapezoidal rule. The code must have the bounds of integration and tolerance. The code is meant to stop when the tolerance between the next and previous value is below 10^-4, given n number of times to sub split the intervals.
My progress...
Hello, this block of code was given on a previous exam
M = [1 3 -2; 7 -5 1];
temp = 0;
for k = M
temp = temp + k(2)
end
temp
And we are supposed to give the final output of temp. I have no idea how one loops over a matrix, not even elements or anything. What the heck does k = M...
Hi Folks,
I am trying to replicate a solution in Matlab for the following problem ##\displaystyle \ddot x + \frac{k}{m}x = \frac{F_o}{m} \sin w_ot##
using 2 first order linear differential equations in Matlab as shown below
tspan=[0 4];
y0=[.02;1]; %Initial Conditions for y(1)=x and...
Hey guys, This is my first post here, so I will apologize in advance in case I'm posting this in the wrong section.
I wrote a very simple function to calculate spherical harmonics in matla, and I used this function during 3 years. Yesterday I found that the function was actually wrong, and...
Hi,
My question is in relation to Matlab.
I'm curious, is there anyway to employ user inputs for function handles?
By this I mean that the user is prompted to enter they're chosen function and the next line of code employs that into a handle.
My quick and rough attempt was...
Hello, here is a list of the order of precedence for computations when programming, at least in MATLAB
1. Parentheses (starting with innermost pair)
2. NOT (~) (left to right)
3. Arithmetic operations (left to right)
4. Relational operations (left to right)
5. AND (&)
6. OR (|)
7...
Hello,
I am preparing for the exam for my Matlab class, and have run into some confusion with Structure arrays. I have a hard time keeping all the concepts straight in my head. I am working on an old exam problem, where this is the structure array, which I will use as an example to demonstrate...
Hello,
I am curious why the following concatenation is not working the way I thought it would.
B = [0 5 1; 2 4 3]
B =
0 5 1
2 4 3
B([1 2], [1 3])
ans =
0 1
2 3
I don't really understand what this command is extracting from the matrix and how it...
Hello, I am confused about a concept,
Suppose I am trying to solve a linear system ##Ax = b##
I want to know why is it when I solve for x, the command is x = A\b. Why would it not be x = b\A. One could see that if you divide x on both sides, then b/x = A. Is this not true for the matrix?
I have found the 2D Fourier transform of a figure and then changed it to a binary image (attached).
I want to find the line of best fit through the longest "axis"? of this figure. What would be the simplest way to accomplish this?
Hi. When I try to this multiplication: t=[0:0.02:1]; f=exp(-t)*sin(t)
Error using *
Inner matrix dimensions must agree.
in Matlab I take the error above and I can not also plot its graph by plot(x,y). Can somebody help me?
Hello,
I am trying to decipher loop codes and I am having a lot of difficulty doing so
Here is an example code
A = 0;
while A < 1
for k=1:5
A = A+(-1)^k;
end
A = A+k;
end
So I thought the while function does something an infinite amount of times. This is what...
First note that I am just learning Mat lab, and running a program created by someone else.
I have a program which is displaying four differential equations on screen, all with various parameters assigned in the beginning. i.e.
alpha=10;
beta=0.04;
gamma=0.020;
etc.
For...
d = x^2 –6*x – 12;
>> ezplot(d)
Error using inlineeval (line 15)
Error in inline expression ==> x.^2 –6.*x – 12
Error: The input character is not valid in MATLAB statements or
expressions.
Error in inline/feval (line 34)
INLINE_OUT_ = inlineeval(INLINE_INPUTS_...
hey pf!
i am trying to plot a contour (topographic) graph the following ##f(x,y) = \frac{1}{x^2+y^2} e^{x-(x^2+y^2)^{.5}}## where ##f(x,y) = k## where ##k = .001## and doubles in size for about 8 iterations. my attempt is here:
x=-3:0.25:3;
y=-3:0.25:3; z=.25:.25:1;
[X,Y]=meshgrid(x,y)...
Hi, all there is an example for gui but I can not do. Could somebody help me. I generated a button in gui then I have to add some function on in. Codes are in the picture. Will I add them under callback function? Why can I not determine where I should I add them. To understand it
what...
Dear all,
I have a coupled system of ode's with an algebraic equation. The equations are as follows,
function dy=lorentz(t,y)
global Vfc;
%fcdata.m
% Data file for the hybrid system with parameters values
%***************************************
% Physical parameters
Rl = 0.024...
Hi
I'm trying to figure out in what energies the bound states of a particle in a symmetric triangular well happen to be, using MatLab(Actually GNU Octave!)
At first I non-dimensionalized the associated Schrodinger equation and got:
\frac{d^2 \varphi}{dy^2}+[ \varepsilon-v(\pm 2y-1) ]\varphi=0...
What is a MATLAB toolbox? Can we rebuild them? Can not we use MATLAB effectively if we do not have toolboxes? Are there any pre-installed toolboxes when we install matlab? How can we see if they are installed or not by using or not using matlab. I have never used a toolbox so I do not know...
Error running optimization. Inputs must be a scalar and a square matri
I am trying to use fminunc using optimtool. But i got the error
Error running optimization.
Inputs must be a scalar and a square matrix.
this is the function i typed in the editor.
function F = fun(x)
F =...
hey pf!
i had a question. my university uses MATLAB for computing on a PC. however, i am using a Macbook. do you think the two can sync with each other? i am waiting on purchasing MATLAB until i know for sure both an communicate with each other.
thanks all!
Hi I wanted to check how to do a Fourier synthesis to recreate a signal from a frequency spectrum. So I basically have the frequency spectrum so I have the power of the fundamental frequency and the harmonics. Is there a way I can do a synthesis to create a time signal?
hey guys,
So I'm working on a MATLAB function that uses simpsons 1/3 rule to find an integral.
This is what I have done so far, but I'm not 100% confident.. I seem to get double when I use greater segments.
If anyone would be able to have a look at give me some tips that would be very much...
Hello everyone
I just want to ask if anyone could help me or at least tell me if it is possible to solve the couple equations using matlab
I saw ode45 but that is for one equation only
Thank uou
Hello all,
Does it occur that anyone here working on OFDM communication systems? I need a MATLAB implementation of such systems in the continuous time. I will provide the math derivations if requested.
Thanks
I'm working on a little project where I want to plot the motion of a projectile with air resistance. The air resistance can be assumed to be proportional to the velocity squared.
F_{f}=-Bv^{2}
F_{f,x}=F_{f}\frac{v_{x}}{v}, \ \ F_{f,y}=F_{f}\frac{v_{y}}{v}
where B depends on the height...
Hello guys,
I would like to put this equation into the MATLAB to calculate the global maximum of mutual information function. In order to do that, I notice that I need a gradient of the function which is described as in attached files.
I do have the vector for P(x) and P(x|spike). Let's...
Hi,
the question is as follows.
I wish to calculate all of the different possible combinations of two vectors in regards to Pythagoras theorem. Not just an element by element operation
My code is as follows;
opposite=(0:30)
adjacent=(0:30)
hypotenuse=sqrt(x1.^2+y1.^2)
When I use...
Dear Math and Physics fans
You have always been so helpful in the past and I was hoping that I could call on your expertise once again.
I want to make a wedge filter in MATLAB so I can determine the orientation of the ellipse of a centered 2D fft.
I tried to make an new image where...
I'm writing a program for simulating the angle distribution of scattered particles from a gold nucleus but I doubt the results. I don't know...But it would be very good if someone check it and give some hints.
I also want to ask should I vary both initial speed and impact parameter in one...
I have a range of sine waves I have obtained in an experiment.
I want to put a measure on the purity of these sine waves - how well the reproduce a theoretical sine wave.
Is there anyway I can analyse the FFT of the sine waves in Matlab and put a measure on the purity of the sine wave...
Hello,
I have just been wondering that given each year we get two new versions of Matlab, for someone like who uses/used Matlab 2001 (or Matlab 7) I am wondering if there's a great reason to move to the recent versions (Matlab 2014a) even when I use only a selected number of toolboxes.
Thanks
This problem was originally a multi objective problem but using scalarization it can be transformed to the following:
Min: -p'*x + u*x'*V*x subject to 1*x=1
-u is the risk aversion index that I wish to vary from .1 to 100
-V is a (4x4) variance covariance matrix
-p is the (4x1) expected...
I have created a contour plot in MATLAB using the following code:
>> NP=40;
>> [RP TP]=meshgrid(linspace(min(RPM),max(RPM),NP),linspace(min(BMEP),max(BMEP),NP));
>> BSFC_IT=griddata(RPM,BMEP,BSFC,RP,TP);
>> NC=12;
>> Fig1=figure;
>> [CT...
So let's say I have 2 matrices A and B. I need to solve 2 eqns involving specific elements of each matrix.
e.g. A(1)+B(2)=4; A(1)-B(2)=2.
Is there any way to do this? My efforts with Fsolve and solve have failed.
Here's what I've done so far:
function F=myfun(A,B)...
I'm trying to plot the evolution of a simple harmonic oscillator using MATLAB but I'm getting non-sense result and I have no idea what's wrong!
Here's my code:
clear
clc
x(1)=0;
v(1)=10;
h=.001;
k=100;
m=.1;
t=[0:h:10];
n=length(t);
for i=2:n
F(i-1)=-k*x(i-1)...
For one of my classes, our project is to write a script that simulates the game of craps. I have no problem with the actual game, but one of the criteria is that after the player wins or loses, we are supposed to prompt them to quit or play again (this is where I'm stuck).
Is there a command...
Hi.
I am currently in a situation where I have a function handle giving as putput an array of doubles. I would like to convert this to a cell array of function handles, each giving a component of the previous array.
The original function handle is produced by a built-in MATLAB function, so...
Hi all,
I have made a BSFC plot in MATLAB with engine data tested on an eddie current dyno, The code I used for it is:
>> NP=40;
>> [RP TP]=meshgrid(linspace(min(RPM),max(RPM),NP),linspace(min(Torque),max(Torqu e),NP));
>> BSFC_IT=griddata(RPM,Torque,BSFC,RP,TP);
>> NC=12;
>>...