Проект:Информационные технологии | |
---|---|
![]() |
![]() | В Википедии есть портал «Компьютерные технологии» |
---|
Эта статья тематически связана с Проектом:Информационные технологии, целью которого является создание качественных и информативных статей на темы, связанные с информационными технологиями. Если вы хотите помочь проекту, то можете отредактировать статью , к которой относится это обсуждение, или посетить страницу проекта, где сможете, помимо прочего, присоединиться к проекту и принять участие в его обсуждении.
Источник: Это практически дословный перевод с английской статьи. OKr 10:52, 10 Ноя 2004 (UTC)
у меня возникает следующая ошибка при использовании одного из примеров в Matlab 7.0
Warning: Matrix dimensions must agree, not rendering mesh.
Warning: Matrix dimensions must agree, not rendering mesh.
Warning: Matrix dimensions must agree, not rendering mesh.
Исправил код в тексте
n=100; k=1:n-1; a=0; b=3; del=(b-a)/n; x=a+del*k; fun=@(x)(x./(1+x.^2)); y=fun(x); I=(sum(y)+(fun(a)+fun(b))/2)*del; I0=1/2*log(10); de=(1-I/I0) %% n=100; k=1:n; a=0; b=10; del=(b-a)/n; x=a+del*(k-1/2); fun=@(x)(x./(1+x.^2)); y=fun(x); I=(sum(y))*del; I0=1/2*log(10); de=(1-I/I0) %% I=quad(fun,a,b); de=(1-I/I0) %% ezplot(fun,[0,10]) hold on
%% int=cumsum(y)*del; plot(x,int); hold on %% dif=diff(y)*del; x1=( +x(n-1:end))/2 plot(x,dif); hold on 80.250.160.252 12:22, 5 апреля 2012 (UTC)mmm
—Dstary 09:13, 17 марта 2010 (UTC) n=100; k=1:n-1; a=0; b=3; del=(b-a)/n; x=a+del*k; fun=@(x)(x./(1+x.^2)); y=fun(x); I=(sum(y)+(fun(a)+fun(b))/2)*del; IO=1/2*log(10); del=(1-I/IO) 80.250.160.252 11:57, 5 апреля 2012 (UTC) (подробнее ↗)
Литератуа [ править код ]
Вызывает некоторые подозрения то, что большинство книг в литературе от одного автора. Похоже на рекламу (ch3k1s7 22:09, 20 февраля 2010 (UTC)) по матлабу мало литературы на русском языке — в основном все дьяконов да потемкин 91.220.220.243 06:00, 22 февраля 2013 (UTC)
I am typing some code for a class but every time I run the function I get the same error:
I know that the problem is a simple index error, but I can’t seem to find it anywhere. Can somebody help me?
Also I’m having the same problem with the following line of code:
EDIT #1:
x2 is defined as 0:0.1:5 and y1 is defined as -5:0.1:5 , but that is what I have been assigned to define them as. And I know exp is not a function because I have used it elsewhere in my file.
EDIT #2:
OK. So if I can’t use my current x and y is there anyway I can define them to keep them on those bounds while still making them the same size?
2 Answers 2
UPDATE:
OK, now that you have confirmed that your variables x2 and y1 contain different numbers of elements, you have a couple of solutions to choose from:
For each variable, you can create a set number of values over the respective ranges using the function LINSPACE. For example:
However, when you compute the result f32 (which will also be a 101-element array), it will only be evaluated at the respective pairs of values in x2 and y1 (e.g. x2(1) and y1(1) , x2(50) and y1(50) , etc.).
If you would rather evaluate f32 at every unique pair of points over the ranges of x2 and y1 , you should instead use the function MESHGRID to generate your values. This will also allow you to have a different numbers of points over the ranges for x2 and y1 :
The above will create x2 and y1 as 101-by-51 arrays such that f32 will also be a 101-by-51 array evaluated at all the points over the given ranges of values.
Previous answer:
The first thing to test is if all the variables you are putting into the equation are the same size or scalar values, which they would have to be since you are using element-wise operators like .^ and .* . For the first equation, see what output you get when you do this:
If they give the same result, or either is [1 1] , then that’s not your problem.
The next thing to check is whether or not you have shadowed the EXP function by creating a variable by the name exp . If you’re running the code as a script in the command window, type whos and see if a variable named exp shows up. If it does, you need to delete or rename it so that you can use the function EXP.
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.