Search Results

Search found 1051 results on 43 pages for 'matlab'.

Page 9/43 | < Previous Page | 5 6 7 8 9 10 11 12 13 14 15 16  | Next Page >

  • MATLAB: Reading floating point numbers and strings from a file

    - by xsound
    I am using the following functions for writing and reading 4098 floating point numbers in MATLAB: Writing: fid = fopen(completepath, 'w'); fprintf(fid, '%1.30f\r\n', y) Reading: data = textread(completepath, '%f', 4098); where y contains 4098 numbers. I now want to write and read 3 strings at the end of this data. How do I read two different datatypes? Please help me. Thanks in advance.

    Read the article

  • implementation of interp1 function of MATLAB in J2ME

    - by Jeeka
    Hi, i am looking to implement the interp1, 1-D data interpolation (table lookup), function available in MATLAB in J2ME or JAVA. here is the link http://www.mathworks.com/access/helpdesk/help/techdoc/ref/interp1.html Is there any library available in J2ME or JAVA which has already implemented the same function ? If not can anybody help me in implementing interp1 function in J2ME or JAVA ?

    Read the article

  • How to override the default text in MATLAB

    - by Richie Cotton
    In MATLAB, when you click File - New - Function M-File, you get a file with the following contents: function [ output_args ] = Untitled( input_args ) %UNTITLED Summary of this function goes here % Detailed explanation goes here end Is it possible to override this behaviour, and specify your own text? (The motivation is that I'm trying to persuade my colleagues to document their m-files more thoroughly, and having default text for them to fill in might encourage them.)

    Read the article

  • Changing scaling of MATLAB Figure

    - by Phil
    I have a figure that displays 20,000 points on the x-axis. So it labels the x-axis from 0 ... 20,000. However, now I would like to scale it from 0 to 50. But when I try to do this in the plot window it just shows me the first 50 points, instead of changing the scale. Is there any straightforward way to do that in MATLAB?

    Read the article

  • Calculating the maximum distance between elements of vector in Matlab

    - by lhahne
    Lets assume that we have a vector like x = -1:0.05:1; ids = randperm(length(x)); x = x(ids(1:20)); I would like to calculate the maximum distance between the elements of x in some idiomatic way. It would be easy to just iterate over all possible combinations of x's elements but I feel like there could be a way to do it with Matlab's built-in functions in some crazy but idiomatic way. Any ideas?

    Read the article

  • Is there a substitute for blockproc in Matlab?

    - by SetchSen
    I've been using blockproc for processing images blockwise. Unfortunately, blockproc is part of the Image Processing Toolbox, which I don't have on my personal computer. Is there a combination of functions in base Matlab that can substitute for blockproc? My initial guess was to use im2col to transform each block into columns, and then arrayfun to process each column. Then I realized that im2col is also a part of the Image Processing Toolbox, so that doesn't solve my problem.

    Read the article

  • 3D plotting in Matlab

    - by Jill
    I'm using the subplot and then surf functions to generate images in 3D in Matlab. How do I get rid of the axes and axis' gridlines and change the color to all yellow or all green or something like that? Thanks.

    Read the article

  • Specifying a callback in Matlab after any runtime error

    - by JmG
    Is there a way to specify code to be run whenever an error occurs in Matlab? Googling I came across RunTimeErrorFcn and daqcallback, but I believe these are specific to the Data Acquisition Toolbox. I want something for when I just trip over a bug, like an access to an unassigned variable. (I use a library called PsychToolbox that takes over the GPU, so I want to be able to clear its screen before returning to the command prompt.)

    Read the article

  • MATLAB plot moving data points in seperate subplots simutaneously

    - by Nate B.
    I wish to visualize the movement of a data point throughout space across a period of time within MATLAB. However, the way I want my figure to display is such that only a single instant is plotted at any given time. That was easy, I simply created a for loop to update my 3D plot display for every set of coordinates (x,y,z) in my data. However, I wish to display 4 different viewing angles of this plot at all times. I am well aware of how to setup subplots within MATLAB, that is not the issue. My issue is getting all 4 of these subplots to execute simultaneously so that all 4 subplots are always displaying the same point in time. I would appreciate if anyone could suggest how to handle this issue. As requested, my code for a figure with a single plot is shown below: datan = DATA; %data in form of x,y,z,a,b,c by column for row# of time points tib=zeros(size(datan,1),12); tib(:,1:3) = datan(:,1:3); tib_ref=tib(1,1:3); for i=1:size(datan,1) tib(i,1:3)=tib(i,1:3)-tib_ref; end angle_to_dircos close all figure('Name','Directions (Individual Cycles)','NumberTitle','off') for cc=1:2 hold off for bb=1:10:size(tib,1); scatter3(tib(bb,1),tib(bb,2),tib(bb,3),'green','filled'); %z and y axes are flipped in polhemus system hold on p0 = [tib(bb,1),tib(bb,2),tib(bb,3)]; p1 = [tib(bb,1)+10*tib(bb,4),tib(bb,2)+10*tib(bb,5),tib(bb,3)+10*tib(bb,6)]; p2 = [tib(bb,1)+10*tib(bb,7),tib(bb,2)+10*tib(bb,8),tib(bb,3)+10*tib(bb,9)]; p3 = [-(tib(bb,1)+100*tib(bb,10)),-(tib(bb,2)+100*tib(bb,11)),-(tib(bb,3)+100*tib(bb,12))]; vectarrow(p0,p1,1,0,0) hold on vectarrow(p0,p2,0,1,0) hold on vectarrow(p0,p3,0,0,1) hold on az = 90; el = 0; view(az, el); xlim([-50,50]); ylim([-50,50]); zlim([-50,50]); xlabel('distance from center in X'); ylabel('distance from center in Y'); zlabel('distance from center in Z'); title('XYZ Scatter Plots of Tracker Position'); hold on plot3(0,0,0,'sk','markerfacecolor',[0,0,0]); p0 = [0,0,0]; p1 = [10,0,0]; p2 = [0,10,0]; p3 = [0,0,100]; vectarrow(p0,p1,1,0,0) hold on vectarrow(p0,p2,0,1,0) hold on vectarrow(p0,p3,1,0,1) drawnow; end end

    Read the article

  • matlab get color

    - by iteratorr
    I am using matlab for cluster visualization. I want to somehow get the color of my current cluster center fill in the plot and draw line of same color to cluster members. How can I get the color?

    Read the article

  • Working with a figure file in Matlab

    - by 49er
    I've got a .fig file showing the intensities of 2d data. How do I obtain the values when I load it in Matlab? Is it even possible? When I try playing with the children properties I am able to obtain only the size of my x and y vectors, not the values themselves which I don't know how to extract.

    Read the article

  • Matlab code works with one version but not the other

    - by user1325655
    I have a code that works in Matlab version R2010a but shows errors in matlab R2008a. I am trying to implement a self organizing fuzzy neural network with extended kalman filter. I have the code running but it only works in matlab version R2010a. It doesn't work with other versions. Any help? Code attach function [ c, sigma , W_output ] = SOFNN( X, d, Kd ) %SOFNN Self-Organizing Fuzzy Neural Networks %Input Parameters % X(r,n) - rth traning data from nth observation % d(n) - the desired output of the network (must be a row vector) % Kd(r) - predefined distance threshold for the rth input %Output Parameters % c(IndexInputVariable,IndexNeuron) % sigma(IndexInputVariable,IndexNeuron) % W_output is a vector %Setting up Parameters for SOFNN SigmaZero=4; delta=0.12; threshold=0.1354; k_sigma=1.12; %For more accurate results uncomment the following %format long; %Implementation of a SOFNN model [size_R,size_N]=size(X); %size_R - the number of input variables c=[]; sigma=[]; W_output=[]; u=0; % the number of neurons in the structure Q=[]; O=[]; Psi=[]; for n=1:size_N x=X(:,n); if u==0 % No neuron in the structure? c=x; sigma=SigmaZero*ones(size_R,1); u=1; Psi=GetMePsi(X,c,sigma); [Q,O] = UpdateStructure(X,Psi,d); pT_n=GetMeGreatPsi(x,Psi(n,:))'; else [Q,O,pT_n] = UpdateStructureRecursively(X,Psi,Q,O,d,n); end; KeepSpinning=true; while KeepSpinning %Calculate the error and if-part criteria ae=abs(d(n)-pT_n*O); %approximation error [phi,~]=GetMePhi(x,c,sigma); [maxphi,maxindex]=max(phi); % maxindex refers to the neuron's index if ae>delta if maxphi<threshold %enlarge width [minsigma,minindex]=min(sigma(:,maxindex)); sigma(minindex,maxindex)=k_sigma*minsigma; Psi=GetMePsi(X,c,sigma); [Q,O] = UpdateStructure(X,Psi,d); pT_n=GetMeGreatPsi(x,Psi(n,:))'; else %Add a new neuron and update structure ctemp=[]; sigmatemp=[]; dist=0; for r=1:size_R dist=abs(x(r)-c(r,1)); distIndex=1; for j=2:u if abs(x(r)-c(r,j))<dist distIndex=j; dist=abs(x(r)-c(r,j)); end; end; if dist<=Kd(r) ctemp=[ctemp; c(r,distIndex)]; sigmatemp=[sigmatemp ; sigma(r,distIndex)]; else ctemp=[ctemp; x(r)]; sigmatemp=[sigmatemp ; dist]; end; end; c=[c ctemp]; sigma=[sigma sigmatemp]; Psi=GetMePsi(X,c,sigma); [Q,O] = UpdateStructure(X,Psi,d); KeepSpinning=false; u=u+1; end; else if maxphi<threshold %enlarge width [minsigma,minindex]=min(sigma(:,maxindex)); sigma(minindex,maxindex)=k_sigma*minsigma; Psi=GetMePsi(X,c,sigma); [Q,O] = UpdateStructure(X,Psi,d); pT_n=GetMeGreatPsi(x,Psi(n,:))'; else %Do nothing and exit the while KeepSpinning=false; end; end; end; end; W_output=O; end function [Q_next, O_next,pT_n] = UpdateStructureRecursively(X,Psi,Q,O,d,n) %O=O(t-1) O_next=O(t) p_n=GetMeGreatPsi(X(:,n),Psi(n,:)); pT_n=p_n'; ee=abs(d(n)-pT_n*O); %|e(t)| temp=1+pT_n*Q*p_n; ae=abs(ee/temp); if ee>=ae L=Q*p_n*(temp)^(-1); Q_next=(eye(length(Q))-L*pT_n)*Q; O_next=O + L*ee; else Q_next=eye(length(Q))*Q; O_next=O; end; end function [ Q , O ] = UpdateStructure(X,Psi,d) GreatPsiBig = GetMeGreatPsi(X,Psi); %M=u*(r+1) %n - the number of observations [M,~]=size(GreatPsiBig); %Others Ways of getting Q=[P^T(t)*P(t)]^-1 %************************************************************************** %opts.SYM = true; %Q = linsolve(GreatPsiBig*GreatPsiBig',eye(M),opts); % %Q = inv(GreatPsiBig*GreatPsiBig'); %Q = pinv(GreatPsiBig*GreatPsiBig'); %************************************************************************** Y=GreatPsiBig\eye(M); Q=GreatPsiBig'\Y; O=Q*GreatPsiBig*d'; end %This function works too with x % (X=X and Psi is a Matrix) - Gets you the whole GreatPsi % (X=x and Psi is the row related to x) - Gets you just the column related with the observation function [GreatPsi] = GetMeGreatPsi(X,Psi) %Psi - In a row you go through the neurons and in a column you go through number of %observations **** Psi(#obs,IndexNeuron) **** GreatPsi=[]; [N,U]=size(Psi); for n=1:N x=X(:,n); GreatPsiCol=[]; for u=1:U GreatPsiCol=[ GreatPsiCol ; Psi(n,u)*[1; x] ]; end; GreatPsi=[GreatPsi GreatPsiCol]; end; end function [phi, SumPhi]=GetMePhi(x,c,sigma) [r,u]=size(c); %u - the number of neurons in the structure %r - the number of input variables phi=[]; SumPhi=0; for j=1:u % moving through the neurons S=0; for i=1:r % moving through the input variables S = S + ((x(i) - c(i,j))^2) / (2*sigma(i,j)^2); end; phi = [phi exp(-S)]; SumPhi = SumPhi + phi(j); %phi(u)=exp(-S) end; end %This function works too with x, it will give you the row related to x function [Psi] = GetMePsi(X,c,sigma) [~,u]=size(c); [~,size_N]=size(X); %u - the number of neurons in the structure %size_N - the number of observations Psi=[]; for n=1:size_N [phi, SumPhi]=GetMePhi(X(:,n),c,sigma); PsiTemp=[]; for j=1:u %PsiTemp is a row vector ex: [1 2 3] PsiTemp(j)=phi(j)/SumPhi; end; Psi=[Psi; PsiTemp]; %Psi - In a row you go through the neurons and in a column you go through number of %observations **** Psi(#obs,IndexNeuron) **** end; end

    Read the article

  • MATLAB : frequency distribution

    - by Arkapravo
    I have raw observations of 500 numeric values (ranging from 1 to 25000) in a text file, I wish to make a frequency distribution in MATLAB. I did try the histogram (hist), however I would prefer a frequency distribution curve than blocks and bars. Any help is appreciated !

    Read the article

  • MATLAB query about for loop, reading in data and plotting

    - by mp7
    Hi there, I am a complete novice at using matlab and am trying to work out if there is a way of optimising my code. Essentially I have data from model outputs and I need to plot them using matlab. In addition I have reference data (with 95% confidence intervals) which I plot on the same graph to get a visual idea on how close the model outputs and reference data is. In terms of the model outputs I have several thousand files (number sequentially) which I open in a loop and plot. The problem/question I have is whether I can preprocess the data and then plot later - to save time. The issue I seem to be having when I try this is that I have a legend which either does not appear or is inaccurate. My code (apolgies if it not elegant): fn= xlsread(['tbobserved' '.xls']); time= fn(:,1); totalreference=fn(:,4); totalreferencelowerci=fn(:,6); totalreferenceupperci=fn(:,7); figure plot(time,totalrefrence,'-', time, totalreferencelowerci,'--', time, totalreferenceupperci,'--'); xlabel('Year'); ylabel('Reference incidence per 100,000 population'); title ('Total'); clickableLegend('Observed reference data', 'Totalreferencelowerci', 'Totalreferenceupperci','Location','BestOutside'); xlim([1910 1970]); hold on start_sim=10000; end_sim=10005; h = zeros (1,1000); for i=start_sim:end_sim %is there any way of doing this earlier to save time? a=int2str(i); incidenceFile =strcat('result_', 'Sim', '_', a, 'I_byCal_total.xls'); est_tot=importdata(incidenceFile, '\t', 1); cal_tot=est_tot.data; magnitude=1; t1=cal_tot(:,1)+1750; totalmodel=cal_tot(:,3)+cal_tot(:,5); h(a)=plot(t1,totalmodel); xlim([1910 1970]); ylim([0 500]); hold all clickableLegend(h(a),a,'Location','BestOutside') end Essentially I was hoping to have a way of reading in the data and then plot later - ie. optimise the code. I hope you might be able to help. Thanks. mp

    Read the article

  • MATLAB clear current figure

    - by rlbond
    I want to clear MATLAB's global CurrentFigure property, because I need a plot that I make to not be overwritten if a careless user uses plot without opening a new figure. I tried set(0, 'CurrentFigure', []); But it doesn't seem to work. Is this impossible?

    Read the article

< Previous Page | 5 6 7 8 9 10 11 12 13 14 15 16  | Next Page >