필터 지우기
필터 지우기

How do I put in a range of negative numbers?

조회 수: 10 (최근 30일)
Tom
Tom 2011년 11월 25일
답변: Disha Patel 2018년 12월 12일
I've got this script: -
m=2
g=9.81
k=0.5
c=sqrt((m*g)/k)
v=[-6.264183904]
t=(-1*(c/2)*log((c+v)/(c-v)))/g
plot(v,t)
and I want my values for v to be equal to a range of values going from -c to 0. I can't seem to make it do it for some reason.

채택된 답변

Image Analyst
Image Analyst 2011년 11월 25일
Try linspace, like this:
m=2
g=9.81
k=0.5
c=sqrt((m*g)/k)
v=linspace(-c, 0, 100);
t=(-1*(c/2)*log((c+v)./(c-v)))/g;
plot(v,t, 'bo-');
grid on;
% Enlarge figure to full screen.
set(gcf, 'units','normalized','outerposition',[0 0 1 1])
Note that because v is now an array some of the slashes needed to be changed to dot slashes.
  댓글 수: 2
Tom
Tom 2011년 11월 25일
That's great thanks. I get the linspace command now I think. What's 'bo-'? And would you mind just explaining the bottom line a bit? Thanks again.
Walter Roberson
Walter Roberson 2011년 11월 25일
'bo-' is Blue lines with circular ("o-shaped") markers, using solid lines to connect the points.
Outerposition is difficult to explain. You can read the documentation about it, http://www.mathworks.com/help/techdoc/ref/axes_props.html#OuterPosition but I find it difficult to manipulate Innerposition and Outerposition to get predictable results.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Disha Patel
Disha Patel 2018년 12월 12일
I have got this script :
close all;
clear all;
clc
n = -10:1:-1;
u(n)= 1;
p=(0.25).^(n).*u(n);
plot(n,p);
I want to scatter function "p" in negative side of the x axis so what should I do if I run this code the error seems like there should be positive and logical value of the variable "n" could anyone help me out of this?

카테고리

Help CenterFile Exchange에서 Subplots에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by