Info
La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.
How to plot a graph in matalab2016?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
When I use plot() it gives an error that the value is not integer.
I want to plot the graph
E=[0.0236;0.0485;0.0889;0.569;0.789;0.894;1]
and
top=[10%;15%;20%;30%;40%;50%]
Please help.
2 comentarios
Respuestas (2)
Rik
el 18 de Mayo de 2017
In general you should copy the entire error stack (all the red text). This makes it easier for others to understand what went wrong.
I noticed 2 things:
- the percent sign marks the beginning of a comment, so top will not be correctly assigned (although I assume that you already did top=[0.10,0.15,0.20,0.30,0.40,0.50];)
- E has 7 values, while top has only 6. It is impossible for plot to know what xy-pairs to make.
0 comentarios
Walter Roberson
el 21 de Mayo de 2017
The call
G = sparse(s,t,1,n,n);
means that you want to create the sparse matrix equivalent of
G = zeros(n, n);
for K = 1 : length(s)
G( s(K), t(K) ) = 1;
end
That can only work if all of the elements of s and all of the elements of t are positive integers, but they are not: they are values like 0.10 and 0.0136
It is difficult to say exactly what your replacement code should be. Possibly
Gs = sparse(i, j, s, n, n);
Gt = sparse(i, j, t, n, n);
if the intention is to create sparse matrix that has the values in s stored at the i and j locations, an that has t stored at the i and j locations. Sparse matrices cannot be multi-dimensional: you can only store a single value at any one index pair.
0 comentarios
La pregunta está cerrada.
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!