Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3957634
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T02:30:56+00:00 2026-05-20T02:30:56+00:00

i have two problems in mathematica and want to do them in matlab: measure

  • 0

i have two problems in mathematica and want to do them in matlab:

measure := RandomReal[] - 0.5
m = 10000;
data = Table[measure, {m}];
fig1 = ListPlot[data, PlotStyle -> {PointSize[0.015]}]
Histogram[data]

matlab:

measure =@ (m) rand(1,m)-0.5
m=10000;
for i=1:m
data(:,i)=measure(:,i);
end

figure(1)
plot(data,'b.','MarkerSize',0.015)

figure(2)
hist(data)

And it gives me :

??? The following error occurred
converting from function_handle to
double: Error using ==> double

If i do :

measure =rand()-0.5
    m=10000;
data=rand(1,m)-0.5

then, i get the right results in plot1 but in plot 2 the y=axis is wrong.

Also, if i have this in mathematica :

steps[m_] := Table[2 RandomInteger[] - 1, {m}]
steps[20] 
Walk1D[n_] :=  FoldList[Plus, 0, steps[n]]
LastPoint1D[n_] := Fold[Plus, 0, steps[n]]
ListPlot[Walk1D[10^4]]

I did this :

steps = @ (m) 2*randint(1,m,2)-1;
steps(20)

Walk1D =@ (n) cumsum(0:steps(n))  --> this is ok i think
LastPointold1D= @ (n) cumsum(0:steps(n))
LastPoint1D= @ (n) LastPointold1D(end)-->but here i now i must take the last "folding"
Walk1D(10)
LastPoint1D(10000)
plot(Walk1D(10000),'b')

and i get an empty matrix and no plot..

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T02:30:57+00:00Added an answer on May 20, 2026 at 2:30 am

    Since @Itamar essentially answered your first question, here is a comment on the second one. You did it almost right. You need to define

    Walk1D = @ (n) cumsum(steps(n));
    

    since cumsum is a direct analog of FoldList[Plus,0,your-list]. Then, the plot in your code works fine. Also, notice that, either in your Mathematica or Matlab code, it is not necessary to define LastPoint1D separately – in both cases, it is the last point of your generated list (vector) steps.

    EDIT:

    Expanding a bit on LastPoint1D: my guess is that you want it to be a last point of the walk computed by Walk1D. Therefore, it would IMO make sense to just make it a function of a generated walk (vector), that returns its last point. For example:

    lastPoint1D = @(walk) (walk(end));
    

    Then, you use it as:

    walk = Walk1D(10000);
    lastPoint1D(walk)
    

    HTH

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to create a simple Console in Tcl/Tk I have two problems. First
suppose we have two numbers i want write program which print common bits subsequent
I have two problems with the below code that I need help fixing: 1)
I have two problems with ListView+images. I get the values for the list from
I have two problems in my current .htaccess. The script below works but has
I have two database tables (lets call them A and B) with many-to-many bridge
I used pole display(E POS) in my POS c# application.I have two major problem
Problem: I have two spreadsheets that each serve different purposes but contain one particular
I actually have two questions regarding the same problem but I think it is
Here's my problem at a high level: We have two business applications. App1 inputs

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.