Posts by Guto • 748 points
44 posts
-
1
votes1
answer646
viewsA: How to increase the size of a vector while maintaining its original shape? MATLAB
The answer to that question is Interpolation!. However, you should not lengthen the value of Y, but decrease the value of X! The reason for this is that reducing the number of values in general has…
-
0
votes1
answer49
viewsA: Load a variable from another funtion
It all depends on how you do the search, Matlab’s website is a good source of resources, although it is in English! There are some ways to solve this problem, I will put the methods I would use in…
-
2
votes1
answer117
viewsA: Resize a vector in Matlab
The first question is relatively simple to solve. If you are sure to have non-zero values in your idF, This becomes very simple. Just use a comparison to Matrix as an index. Below I put some…
-
0
votes1
answer119
viewsA: Matlab code error
This seems to me an error in the function input size. What is the size of the variable Grafo? If the variable Grafo is empty, it has zero dimension. If you ask for the number of variables in…
-
0
votes1
answer233
viewsA: Save file to columns
If I understood what you want, you want to have only the two initial columns and then have only the data you generated in columns. To do this, one way is to create the data in just one matrix and…
-
0
votes1
answer240
viewsA: Change of Matlab Directory
This is normal according to what you want to do in Matlab. If you don’t have any scripts or anything like that, change the Matlab directory in the same interface, either as "Unix" directly at the…
-
1
votes2
answers619
viewsA: standard deviation of all elements of a matrix in MATLAB?
Given a matrix a, you can always access all the elements using a(:). Example: a=magic(3) a = 8 1 6 3 5 7 4 9 2 a(:) ans = 8 3 4 1 5 9 6 7 2 In your case, just use std(a(:)) or instead of std(a).…
-
1
votes2
answers78
viewsA: Loop step size for MATLAB
Loop control works with A= inicio:passo:final; In your case for x=0.15:0.15:10 ... Solves the problem.
-
1
votes1
answer294
viewsA: How to change the color of a curve when the values increase?
Just use the data as color input and change the colormap of the graph. For example below: import numpy as np import matplotlib.pyplot as plt #Meus dados randomicos x = np.random.random(10) y =…
-
2
votes2
answers133
viewsA: How to read the size of a mat file?
Besides Marcelo Uchimura put in the answer, It is worth remembering that when you use matrix=load('data.mat') or matrix=load('data.mat','variavel') You have as answer a structure, not the saved…
-
1
votes1
answer73
viewsA: How to plot a graph using a Function curve
Although Stackoverflow is not a place for homework, besides you show what you tried the issue of plotting a curve can be interesting for other future issues. The problem seems to be in its…
-
1
votes1
answer295
viewsA: How to customize matplotlib Plots, in a more Clusterization-oriented way?
As far as I could find, there is no tool that gives the difference between the points or tell which ones are closer or further away. My suggestion is to use other functions to make this…
-
0
votes2
answers2055
viewsA: Customize / set the order X-axis graph matplotlib bars
There are some ways to settle this, as you said, a sort_index() may solve, but it depends on how flexible the algorithm makes Sorting. Below follows a solution with the use of an extra dataframe and…
-
2
votes3
answers183
views -
0
votes2
answers3737
viewsA: Save txt file to Matlab
This problem is a classic problem windows vs Unix. In addition to the response of ederwander, an option I normally use is the save function, I don’t know if she does Appendix, but in the manual she…
-
1
votes3
answers559
viewsA: Python - Find numbers larger than average
Besides the patrick’s response, you can use other libraries that can make your life easier. In this case, Numpy can make your life much easier. Just use the numpy.Mean and the numpy size. import…
-
0
votes1
answer272
viewsA: How to plot this signal in Matlab?
Your script has several errors, but they are all easily solved. I will initially put some tips on how to solve problems when programming! Pay attention to the return of Matlab When you spin…
-
0
votes1
answer142
viewsA: Assignment of lists in a matrix
You can use Dataframe of pandas and do that. I don’t know an equal tool in numpy, but the pandas does this in a very simplified way. Follow an example code: import pandas as pd import numpy as np…
-
1
votes1
answer357
viewsA: No return function in Matlab
Adding to link previously placed, a function can be completely empty or have only input parameters, just have nothing as output. Examples: %%Em um arquivo chamado v.m function v(a,b) % a funcão V…
-
1
votes2
answers135
viewsA: Adding points in a known data range
I fully agree with the commenting about changing the data you will give as input. However, I know that we do not always have the data as we need. It would be more right maybe to make one…
-
2
votes1
answer4440
viewsA: Concatenate pandas dataframes with different column names
I don’t think there’s anything more general, but I’d love to find an answer to that. Looking at the Pandas Handbook on merging, Both the concat as to the append create a copy. It is possible to use…
-
1
votes2
answers452
viewsA: Linear Regression in Various Products
Given what seems to be your data, I was able to solve using the attribute .loc of the pandas dataframe. An example of how I did: import pandas as pd import numpy as np df1 =…
-
0
votes2
answers170
viewsA: How to convert Matlab functions to Rstudio?
TL;DR: You have to translate by seeing what a code does and implementing in the other language. More details: In fact, your question is not very clear, but assuming you need to translate the…
-
1
votes1
answer2967
viewsA: Figure Legends
Your problem is in your legend. In your code you have: line_up, = plt.plot([1,2,3], label='Teórico', color='blue') line_down, = plt.plot([2,3,1], marker='o', markersize=4, label='Simulado',…
-
0
votes1
answer110
viewsA: How to transform a numpy.array of size 497305 into a smaller 4999 without adding new elements in the calculation?
Considering that you only need to make an average of the values obtained every 100, you can simply make a new Matrix with average of every 100 points. To do this it is necessary to take precautions…
-
0
votes1
answer678
viewsA: How to assign values to a vector?
In this case, you do not want to create an array that takes 5 values, but rather create an array with the 5 desired values. To use syntax similar to what you want, the important thing is to see how…
-
0
votes1
answer131
viewsA: Initialize the graph in matplotlib and then insert elements
From what I found, you must use plt.ion() along with plt.draw() just like this example or this question in the OS. Unfortunately I can’t test because I’m in a python text mode for now. I do an…
-
1
votes1
answer361
viewsA: How to mount an array in python with undefined value of i and j
Maybe your problem is with range. If I’m gonna use n=3, range(2,n-1) returns [] and he doesn’t pass the loop, leaving A without any alteration and also does not create i,j, and other variables…
-
1
votes1
answer1018
viewsA: trapeze rule in Matlab!
Given that Matlab is a very versatile software for calculation with matrices and data analysis, most widely used algorithms for data analysis have a version built-in. What you are wanting to…
-
0
votes1
answer50
viewsA: Solve code in Matlab?
Initially you have an error in your expression A2 x^2, considering this as A2*x^2, let’s get to the problem. Matlab has a very simple syntax: If you have a and want to multiply a times x, just use…
-
0
votes1
answer231
viewsA: How to return output argument in Matlab?
Input and output is very simple in Matlab. But to answer you, you need to put where you are using Ai and how you’re calling your job. After all, if you are using the function to calculate something,…
-
1
votes1
answer396
viewsA: Wrong square parentheses (square brackets)?
The problem is syntax. You copied the code without looking at what the python function uses as input. With a look at the manual it is possible to see that a direct copy Matlab->python does not…
-
1
votes1
answer1835
viewsA: Indexerror: index 4 is out of Bounds for Axis 0 with size 4
You have two big issues in your code (plus a small formatting failure inside the loop). One is in your range, the other in vector allocation. Range: For a size N vector, Python uses indices from 0…
-
3
votes1
answer3728
viewsA: Logarithmic Scale Graph with Python
The problem is the call order. Call plt.yscale('log') and then call plt.ylim(ymax=sorted(y)[-1]+100,ymin=sorted(y)[0]-1). Note that I added 100 to the maximum value, due to the logarithmic scale. If…
-
0
votes1
answer118
viewsA: I’m trying to get my chart started from position 0 using hist()
I found this answer who uses the pylab.hist as the parameter histtype="stepfilled" . If this doesn’t work, you can try using asymmetrical bars, increasing the size of problematic bars. If none of…
-
1
votes1
answer425
viewsA: How to sum a column of a file and visualize with . Plot(Kind = 'bar')?
Well, you haven’t tried everything. Your presentation is a little bad, but if I guessed right what you’re wearing, it should help. Initially what you show is a table that does not have much to add…
-
4
votes1
answer1394
viewsA: How to improve a bar graph whose values are very close in Python?
Besides the suggestion already given in the comment (change the color), it is worth changing the xticks and mainly yticks for fewer values. Do not use all values as this decreases the ability to…
-
0
votes1
answer134
viewsA: Syntax problem when compiling modeling in Lingo
Hello, This question is tagged as MATLAB, but usually Matlab is not compiled (at least from the user’s point of view). If this is from Matlab, let’s go to comments: MIN is another variable or…
-
0
votes1
answer53
viewsA: error in isempty function
The function isempty accepts only one parameter, but its code has two. If you use if isempty(pos_erro) must solve.
-
0
votes2
answers62
viewsA: MATLAB - Data is lost when closing the FOR loop
The answer given by Tied --alias, I think not all elements will be zero also-- works for if you want to put all points on a line, if the intention is to leave all points on a matrix, the code…
-
0
votes1
answer69
viewsA: How to turn a random vector into an ordered vector without losing correlation in Matlab
This may be a fault in the function that is using the vector A. A better option is to find out the origin of the problem, but the solution that is possible based on your question is below. Create a…
-
0
votes1
answer1421
viewsA: Calculation of the divergent rotational of a function in Matlab
You have two options here. To be using 2*x is necessary to symbolic function of MATLAB. If this is the case, you can use this direct example to help: syms x y z; divergence([x^2 2*y z], [x y z]) If…
-
2
votes1
answer452
viewsA: Bar graph generated with Python has become unreadable. How to improve it? How to work with a dataset of more than 1 million lines?
Half answer, half comment. Take a look at this question/answer: https://stackoverflow.com/questions/45855794/plotting-too-many-lines-in-matplotlib-out-of-memory It is based on the use of capacity…
-
0
votes1
answer648
viewsA: Store values with the "for" command
I’m not sure if my method works with your system, because I don’t know exactly what you need to save, because I can’t run your code (I don’t have your image, if you comment, I can change it…