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 6810249
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T20:11:01+00:00 2026-05-26T20:11:01+00:00

In Matlab, I can use logspace(A,B,N) to generate a vector of length N ,

  • 0

In Matlab, I can use logspace(A,B,N) to generate a vector of length N, containing points between 10^A and 10^B evenly spaced along a logarithmic axis. However, because of the nature of the logarithm, these points usually end up at data points which make no sense in themselves, and I have to create a logspace with a very large number of points if I want to make sure that a certain data point is exactly represented in the vector.

Is there a way for me to specify certain data points that should be included in the vector?

For example, logspace(1,10,30, [25 50 75]) would generate a vector of lenght 30 with points distributed almost equally along a logarithmic axis, but making sure that all the points 25, 50 and 75 are included.

  • 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-26T20:11:01+00:00Added an answer on May 26, 2026 at 8:11 pm

    Perhaps you are doing some sort of plot and what you need is the reference points for those specific values. If that’s the case you can also handle the logspace vector separately to the special values, for example, by overlaying two plots.

    x = logspace(A, B, N);
    y = f(x);                       % (whatever function or manipulation you want)
    
    xSpecial = [25, 50, 75];
    ySpecial = f(xSpecial);
    
    plot(x, y);                     % plot function curve
    hold on;
    plot(xSpecial, ySpecial, 'ro'); % overlay special points with red circles
    

    Otherwise I like @reve_etrange’s idea of simply adding those specific points into your vector.

    Update

    In a case like this where the calculations for each element do not depend on (1) the order of elements or (2) the values of the other elements in the vector, there is no need to sort the input for the purpose of calculation – and especially if you want to treat the special values differently when plotting.

    Instead, just tack on the special values at the end, and then split the output vector to get the special outputs.

    xRegular = logspace(A, B, N);        % N regular logspace values
    xSpecial = [25, 50, 75];             % special particular values
    
    xCombined = [xRegular, xSpecial];
    
    yCombined = f(xCombined);            % whatever calculation you are doing
    
    yRegular = yCombined(1:N);           % calculated values for xRegular
    ySpecial = yCombined(N+1:end);       % calculated values for xSpecial
    
    % e.g. plot with special points
    plot(xRegular, yRegular);
    hold on;
    plot(xSpecial, ySpecial, 'ro');      % red circles indicate special points
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When Matlab is installed in its 64 bit version, it can use only 64
How can I add a vector to a matrix in Matlab, in a manner
I have recently found that Matlab can use LaTeX character sequences. However, they only
How can I use MATLAB's Symbolic Toolkit to symbolically evaluate derivatives from C or
In matlab we can use filtfilt function to filter out data which implements forward
How can I use MATLAB to replicate Photoshop filters and actions ? Is there
In matlab, we can use pcolor to show the magnitude of data in color.
I have just found that I can use the function trapz in Matlab to
In matlab one can use dbstack to retrieve the call stack at the current
I'm looking for a library I can use for C++ or MATLAB so that

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.