Matlab Help

Recommended Videos

Lunar Shadow

New member
Dec 9, 2008
653
0
0
Hello everyone. I am currently taking a Matlab course a requirement for my major, but unfortunately the teacher quite frankly sucks at teaching. I have failed this class once already and would like to avoid that this time. So here is the scenarion I need help with.

I have a text file file in which variable have been put into a single row. The first part wants me to take these and but the variables into vectors based on what they are a variable. The vectors are in order (Theta, velocity, height, volume) and repeat. Wha t I need help with is getting those seperated into their respective vectors. One other issue I am having is another part where i have to read them into a matrix, which I have done. THe problem now is that I do not know how to plug these variables into the equation ins such a way it uses all of them and forms a coresponding vector for the function's answer. Any help would be appreciated.
 

Zwilorg

New member
Sep 11, 2008
119
0
0
i can´t understand what you are really asking on point 1... but you want to write a *.txt file with all those values? try


txt(1,1)=Theta;
txt(1,2)=velocity;
txt(1,3)=height;
txt(1,4)=volume;


DLMWRITE('"insertname".txt',txt,'delimiter',',','newline','pc','-append')

it will creat the *.txt file on the current folder matlab is working on (wich is normally the one you are working with the *.m file hehe)

Point 2

you want to create an equation?

just use the numbers you have and creat it like

V=volume;
T=Theta;
v=velocity;
H=height;

Something=(V*T*v)./H (the ./ is in the case you have matrix you will notice that only using / maybe not work every time ^^)


and you want to type it on the *.txt?

just add

txt(1,5)=Something;



if what i said is not what you want please explain better ^^ i have been working with matlab for 2 years now :S
 

Lunar Shadow

New member
Dec 9, 2008
653
0
0
Zwilorg said:
i can´t understand what you are really asking on point 1... but you want to write a *.txt file with all those values? try


txt(1,1)=Theta;
txt(1,2)=velocity;
txt(1,3)=height;
txt(1,4)=volume;


DLMWRITE('"insertname".txt',txt,'delimiter',',','newline','pc','-append')

it will creat the *.txt file on the current folder matlab is working on (wich is normally the one you are working with the *.m file hehe)

Point 2

you want to create an equation?

just use the numbers you have and creat it like

V=volume;
T=Theta;
v=velocity;
H=height;

Something=(V*T*v)./H (the ./ is in the case you have matrix you will notice that only using / maybe not work every time ^^)


and you want to type it on the *.txt?

just add

txt(1,5)=Something;



if what i said is not what you want please explain better ^^ i have been working with matlab for 2 years now :S
Sorry. Lemme clarify. :The txt file already has numbers in it, but I need to read those numbers and split them into their own 1 row matrices( as in a 1 row matrix for theta, 1 for velocity, etc). The second part, I have the variables all as one matrix, but need to make another 1 row matrix with the variables in the 1st matrix.
 

Zwilorg

New member
Sep 11, 2008
119
0
0
let´s try it again then :p


Point 1:

clc
clear all

A=[1 1 1 1
2 2 2 2
3 3 3 3
4 4 4 4];

then row´s you say

C=A(1,:)

C = 1 1 1 1

D=A(2,:)

D= 2 2 2 2

E=A(3,:)

E= 3 3 3 3

F=A(4,:)

F= 4 4 4 4


Point 2:

exactly the same has in Point1 :S extract in one input in another i really can´t see what is hard on that